Android Plugin-apkplug Framework Boot-02

Source: Internet
Author: User

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?
01 try
02 {
03  FrameworkInstance frame=FrameworkFactory.getInstance().start(null,Launcher.this,MyProperty.getInstance(this.getApplicationContext()));
04  }catch(Exception ex){
05      System.err.println("Could not create : "+ ex);
06      ex.printStackTrace();
07      StringBuffer buf=newStringBuffer();
08      buf.append("插件平台启动失败:\n");
09      buf.append(ex.getMessage());
10      Toast.makeText(this,"插件平台启动失败",Toast.LENGTH_SHORT).show();
11  }


The framework is embedded in the app and started successfully, and the next article explains how to get plugins and information through Systembundle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.