You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-6Lines changed: 27 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Android Dynamic Loader is a plugin system. The host application is like a browser, but instead of load web pages, it load plugins which runs natively on Android system.
4
4
5
-
You can download the demo from <https://github.com/mmin18/AndroidDynamicLoader/raw/master/host.apk>
5
+
You can download the demo from <https://github.com/mmin18/AndroidDynamicLoader/raw/master/host.apk> (35k).
6
6
7
7
## How to run the sample plugins
8
8
@@ -23,16 +23,37 @@ If it shows "device not found", make sure your phone is connected or simulator i
23
23
24
24
Since we don't specific a default entry in **workspace.properties**, it will popup a window and let you choose one. I suggest bitmapfun.
25
25
26
+
## About UI Container
27
+
28
+
In a normal Android application, we use Activity as the root UI container. But since Activity is registered in AndroidManifest.xml, and we can't modify manifest in runtime, we must find an alternative UI container - Fragment.
29
+
30
+
The Fragment itself, interduced in Android 3.0 Honeycomb, is a perfect UI container, and it has lifecycle and state management.
31
+
32
+
Once the plugin and its dependency is downloaded, an Activity (MainActivity.java) will be started, create an instance of the specific fragment, and add the fragment into the root view.
33
+
34
+
See the [HelloFragment.java](https://github.com/mmin18/AndroidDynamicLoader/blob/master/workspace/sample.helloworld/src/sample/helloworld/HelloFragment.java) sample.
35
+
26
36
## About URL Mapping
27
37
28
-
// TODO:
38
+
Since we use Fragment as UI container, each page is implemented in Fragment instead of Activity. So how do we start a new page?
39
+
40
+
We use URL, just like a browser does. For instance, in a browser, we open `http://mydomain.com/helloworld.html`. In plugins, we open `app://helloworld`.
41
+
42
+
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("app://helloworld"));
43
+
startActivity(i);
44
+
45
+
Each host is mapped to a single fragment, you define the url mapping table in **project/fragment.properties**.
46
+
47
+
See the [helloworld fragment.properties](https://github.com/mmin18/AndroidDynamicLoader/blob/master/workspace/sample.helloworld/fragment.properties) sample.
29
48
30
49
## Folders
31
50
32
-
**/Host** contains the host application (build as host.apk).
51
+
`/Host` contains the host application (build as host.apk).
52
+
53
+
`/tools/update.sh` checks your environment and helps you config your plugins. You should always run it once after git clone or create a new plugin.
33
54
34
-
**/tools/update.sh** checks your environment and helps you config your plugins. You should always run it once after git clone or create a new plugin.
55
+
`/workspace/sample.helloworld` is a most simple plugin.
56
+
`/workspace/sample.helloworld/fragment.properties` defines the url mapping of your fragments.
35
57
36
-
**/workspace/sample.helloworld** is a most simple plugin.
37
-
**/workspace/sample.helloworld/fragment.properties** defines the url mapping of your fragments.
58
+
`/site/***/site.txt` is the definition file for all the plugins files, dependency and fragments url mapping table.
0 commit comments