This article is based on the Apkplug v1.6.7 version, the latest way to the official website of the latest news to prevail
A Apkplug framework requires a library file (host) to get the latest library files from Http://git.oschina.net/plug/apkplugSDK
At the same time can download the latest Apkplugdemo source code Http://git.oschina.net/plug/apkplugDemos
libs--
--libndkfoo.so Armeabi armeabi-v7a MIPS x86
--bundle (version number). jar
Add the above file to the host app's Libs directory
Two Androidmanifest.xml permissions configuration
Plug-in platform requires a few basic permissions configuration, please add the following several permissions to the project Androidmanifest.xml
<!--plugin platform requires permissions! --<uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE" ></uses-permission> & Lt;uses-permission android:name= "Android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> <uses-permission android: Name= "Android.permission.INTERNET"/>
add a bit to the <application></application> node <!-- Plug-in platform required configuration! - <activity Android:name= " Org.apkplug.app.apkplugActivity " android:theme=" @style/android: Theme.light " android:configchanges=" Orientation|keyboardhidden " /> Three-start Apkplug framework you can start the framework in the app's application code as follows (not limited to application) public frameworkinstance Start (List activatorlist,context appcontext,propertyinstance property) public frameworkinstance Start (List activatorlist,context appcontext,propertyinstance Property,displaymetrics dm2) 1.activatorlist is a bundleactivator list (can be null) These bundleactivator start at the frame (System level) 2.PropertyInstance Framework to save configuration information interface &nbsThe p; //framework obtains locally saved variables through this interface public String GetProperty (string key); The //framework sets local variables through this interface public void SetProperty (String key,string v); //Frame startup will automatically install the file provided by this function "file:" +apk file path (1.6.7 is not recommended to use later Can be replaced with Bundlecontrol) public string[] AutoInstall (); When the //framework starts, it automatically installs and starts the file provided by the function "file:" +apk file path ( 1.6.7 not recommended to use Bundlecontrol instead) public string[] AutoStart (); //call Frameworkinstance.shutdown () when exiting the app in debug mode debug mode; All plugins will be removed public boolean Debug (); Four framework boot successfully obtained FRAMEWOrkinstance Interface Framework starts successfully returns the Org.apkplug.app.FrameworkInstance interface, which is the interface where the host application communicates with the Apkplug framework and plug-ins. //Stop frame public void shutdown (); //get the systembundle of the frame The Apkplug framework starts when it creates a systembundle it's Bundleid for 0 while it can't be stopped and unloaded, and our section communicates public bundles through it with other plugins Getsystembundle (); //systembundle plug-in context Bundlecontext public BundleContext Getsystembundlecontext (); startup code: view sourceprint?
03 |
FrameworkInstance frame=FrameworkFactory.getInstance().start( null ,Launcher. this ,MyProperty.getInstance( this .getApplicationContext())); |
05 |
System.err.println( "Could not create : " + ex); |
07 |
StringBuffer buf= new StringBuffer(); |
08 |
buf.append( "插件平台启动失败:\n" ); |
09 |
buf.append(ex.getMessage()); |
10 |
Toast.makeText( this , "插件平台启动失败" ,Toast.LENGTH_SHORT).show(); |
The framework is embedded in the app and started successfully, and the next article explains how to get plugins and information through Systembundle