DroidPlugin is a new Plugin Framework developed and maintained by the Android app-store team at Qihoo 360 (NYSE:QIHU). It enables the host app run any third-party apk without installation, modification and repackage, which benefit a lot for collaborative development on Android.
##Problems to be solved:
-
Unable to send
Notification
with custom Resources,eg:a. Notification with custom RemoteLayout, which means
Notification
'scontentView
,tickerView
,bigContentView
andheadsUpContentView
must be null.b. Notification with icon customized by R.drawable.XXX. The framework will transform it to Bitmap instead.
-
Unable to define specified
Intent Filter
for the plugged app'sService
、Activity
、BroadcastReceiver
andContentProvider
. So the plugged app is invisible for the outside system and app. -
Unable to support all
LaunchMode
ofActivity
, has problems with Activity stack management.Activity
'sonNewIntent
method may not be called (This is a bug, will be fixed in the future). -
Lack of
Hook
to theNative
layer, thus apk (e.g. a majority of game apps) withnative
code cannot be loaded as plugin.
##Features:
- Compatible to Android 2.3 and later versions
- Given its .apk file, the plugged app could be run either independently or as plugin of the host, NO source code needed.
- Unnecessary to register the plugged app's
Service
、Activity
、BroadcastReceiver
、ContentProvider
in the host. - The plugged app are recognized as Installed by the host and other plugged apps
- Very low level of code invasion, in deed just one line code to integrate DroidPlugin into the host app.
- Complete code level separation between host and plugged apps, only system level message passing method provide by Android allowed.
- All system API supported
- Resources management are also completely separated between host and plugged apps.
- Process management for plugged apps, idle processed of the plugged app will be timely recycled to guarantee minimum memory usage.
- Static broadcast of plugged app will be treated as dynamic, thus the static broadcasting will never be trigger if the plugged app are not activated.
##Usage:
####Integrate with the host apps
It is very simple integrate Droid Plugin to your proejct:
-
Import Droid Plugin project to your project as a lib.
-
Include following attributes in host's
AndroidManifest.xml
:<application android:name="com.morgoo.droidplugin.PluginApplication" android:label="@string/app_name" android:icon="@drawable/ic_launcher" >
-
Or, if you use customized
Application
,add following code in the methodsonCreate
andattachBaseContext
:@Override public void onCreate() { super.onCreate(); PluginHelper.getInstance().applicationOnCreate(getBaseContext()); //must behind super.onCreate() } @Override protected void attachBaseContext(Context base) { PluginHelper.getInstance().applicationAttachBaseContext(base); super.attachBaseContext(base); }
-
All
provider
'sauthorities
value in DroidPlugin'sLibraries\DroidPlugin\AndroidManifest.xml
default to becom.morgoo.droidplugin_stub_P00
, e.g. :<provider android:name="com.morgoo.droidplugin.stub.ContentProviderStub$StubP00" android:authorities="com.morgoo.droidplugin_stub_P00" android:exported="false" android:label="@string/stub_name_povider" />
You'd better change it to avoid conflict with other instances, e.g.:
<provider 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 change
PluginManager.STUB_AUTHORITY_NAME
to your value:PluginManager.STUB_AUTHORITY_NAME="com.example.droidplugin_stub"
####Install、Uninstall or Upgrade the plugged app:
-
Install/Upgrade, use this method:
int PluginManager.getInstance().installPackage(String filepath, int flags);
For installation,
filepath
set to path of the .apk file, andflags
set to 0.For upgrade,
filepath
set to path of the .apk file, andflags
set toPackageManagerCompat.INSTALL_REPLACE_EXISTING
. -
Uninstall, use this method:
int PluginManager.getInstance().deletePackage(String packageName,int flags);
packageName
is package name of the plugged app,flags = 0
。 -
Activate
Just use android's API, same for communication between components.
Please feel free to report bugs or ask for help via email.
##Who is using Droid Plugin?
Translated by Ming Song(gnosoir@hotmail.com)