GitHub Address:
Droidplugin is a mobile phone assistant implements a new plug-in mechanism on Android: It can run the APK file without installing or modifying it, which is a mechanism for improving the architecture of large apps. The realization of multi-team collaborative development has some advantages.
Defined:
Host program : The host of the plugin.
plug-in : Free to install running APK
Limitations and defects:
Notification with custom resources cannot be sent in the plug-in, for example: a. Notification B. Icon with custom Remotelayout the notification specified by the R.DRAWABLE.XXX (the plug-in system automatically converts it to bitmap)
You cannot register some service, Activity, Broadcastreceiver, ContentProvider, and other components with special intent filter in the plugin for Android and other apps that have already been installed.
Lack of hooks for native layer, some apk support with native code is not good, may not run. For example, some games cannot be run as plugins.
Characteristics:
Support Androd more than 2.3 system
Plugin APK does not need to make any changes at all, can be installed independently, or can do plug-in operation. To run an APK in plug-in mode, you don't need to recompile and know the source code.
The four components of the plugin do not need to be registered in the host program at all, support service, Activity, Broadcastreceiver, contentprovider four components
Between the plug-ins, the host program and the plug-in will think each other has been "installed" on the system.
API low-Intrusive: very few APIs. The host program simply needs a single line of code to integrate the droid Plugin
Hyper-Isolation: Full code-level isolation between plug-ins, plug-ins, and host: You cannot call each other's code. Communication can only be done using the Android system-level communication method.
Support for all system APIs
Resources are completely isolated: between the plug-ins, and host to achieve a complete separation of resources, there will be no resource channeling situation.
Implementation of process management, plug-in empty process will be timely recovery, low memory consumption.
Static broadcasts of plug-ins are treated as dynamic, and static broadcasts are never triggered if the plug-in is not running (that is, no plug-in process is running).
How to use:
Integration
The integration of the Droid plugin project in host is simple:
We only need to apply the Droid plugin as a Lib project to the main project, and then:
Using the plugin's com.morgoo.droidplugin.PluginApplication in Androidmanifest.xml:
Android:label= "@string/app_name"
android:icon= "@drawable/ic_launcher"
If you use custom application, you will need to add the following code to your custom application Classoncreate and Attachbasecontext methods:
@Override
public void OnCreate () {
Super.oncreate ();
This must be done after the Super.oncreate method, the order cannot be changed
Pluginhelper.getinstance (). Applicationoncreate (Getbasecontext ());
}
@Override
protected void Attachbasecontext (Context base) {
Pluginhelper.getinstance (). Applicationattachbasecontext (base);
Super.attachbasecontext (base);
}
Libraries\droidplugin\androidmanifest.xml all the provider corresponding authorities in the plugin into their own, The default is com.morgoo.droidplugin_stub_P00, as follows:
Android:name= "Com.morgoo.droidplugin.stub.contentproviderstub$stubp00"
Android:authorities= "com.morgoo.droidplugin_stub_P00"
Android:exported= "false"
Android:label= "@string/stub_name_povider"/>
Can be modified to its own package name, such as: com.example.droidplugin_stub_P00 to prevent conflicts with other users of this plugin:
Android:name= "Com.morgoo.droidplugin.stub.contentproviderstub$stubp00"
Android:authorities= "com.example.droidplugin_stub_P00"
Android:exported= "false"
Android:label= "@string/stub_name_povider"/>
and modify the value of Pluginmanager.stub_authority_name for you:
Pluginmanager.stub_authority_name= "Com.example.droidplugin_stub"
Integration is complete.
Install and Uninstall plugins:
To install and update the plugin , use the following methods:
int pluginmanager.getinstance (). InstallPackage (String filepath, int flags)
Description: Install plug-in into the plug-in system, FilePath is the plugin apk path, flags can be set to 0, if you want to update the plug-in, then set to Packagemanagercompat.install_replace_ Existing return value and what it means see the related fields in the Packagemanagercompat class.
To uninstall the plugin , use the following method:
int pluginmanager.getinstance (). Deletepackage (String packagename,int flags);
Description: From the plug-in system to uninstall a plug-in, PackageName pass the plug-in package name, Flags pass 0.
Launch Plugin : The activity that launches the plugin, the service, and so on, is the same as the app you launched and installed on the system, using the relevant APIs provided by the system. This is also true for inter-component communication.
Implementation principle:
Please see source code
Who is using:
Mobile phone Assistant
If you want your project to be displayed here, please send an email to zhangyong232#gmail.com
Support:
You can submit a bug report in your project, or you can send a message to ask for help.
Dynamically loaded Android plugin framework