Reduce application volume based on Apkplug call SHARESDK component

Source: Internet
Author: User

An introduction:

Use the Apkplug plug-in framework to SHARESDK components to enable dynamic load and reduce application volume on demand.

SHARESDK is a great mobile social sharing and commenting tool, and we believe we can do without it in the development of our applications. But when we integrate SHARESDK, we also encounter some problems.

1. SHARESDK package is relatively large, the combination of multiple domestic sharing platform after its SDK package size should be more than 1M, which is not a small load for the application.

2. We will inevitably need to copy its resource files into the RES resource directory of the application in the integration SHARESDK process, which can cause interference to our post-application maintenance.

Based on the above two situations, I would like to sharesdk the whole component through the Apkplug framework, when the user needs to dynamically load from the server to the local, so it is convenient to solve the above two problems.

The development library used by the two projects

Apkplugv2.7.5 version (must be v2.7.5 or later, otherwise it will not work)

Apkplug plug-in hosting service v1.8.0 version above

ShareSDKv2.10.7 (using the latest version of demo)

Three project directory structure

Sharesdkmain---main application demo demo

Implementation of Sharesdkplug---SHARESDK components

Plugsharesdk1.0.0.jar--Component Call Library

Four use steps

    1. Add the Apkplug framework Main Library Bunde2.7.5.jar "200k" to the main application Libs directory
    2. Add the Apkplug plug-in hosting service SDK "200k" to the main app Libs directory
    3. Add the SHARESDK component call Library Plugsharesdk1.0.0.jar "20k" to the host Libs directory
    4. Configuring Apkplug and SHARESDK required permissions and activity "can be extracted directly from the Sharesdkmain project configuration document of the source code"
Five calls to the SHARESDK component

After the above steps are configured, you can use the SHARESDK component, which is very simple and takes the sharing function as an example

1. First initialize the sharesdkagent (defined in the Plugsharesdk1.0.0.jar package)

Sharesdkagent agent=new sharesdkagent (This,frame.getsystembundlecontext ());

2. Create a shared data bean plugshareinfo (defined in the Plugsharesdk1.0.0.jar package)

Final Plugshareinfo oks=new Plugshareinfo () oks.setaddress ("Beijing"); Oks.settitle ("Apkplug Share components function"); o Ks.settitleurl ("http://www.apkplug.com"); Oks.settext ("Apkplug is a modular framework under Android, SHARESDK is a great social sharing component, In the idea of not repeating wheels, we make SHARESDK into plug-ins. For details see official website http://www.apkplug.com ");//oks.setimagepath (testimage); Oks.setimageurl (" Http://img.appgo.cn/imgs/sharesdk /content/2013/07/25/1374723172663.jpg "); Oks.seturl (" http://www.apkplug.com ");//oks.setfilepath (testimage); o Ks.setcomment ("It is recommended to use the Apkplug framework to reduce application volume and to provide development efficiency. Oks.setsite (getString (R.string.app_name)); Oks.setsiteurl ("http://mob.com"); Oks.setvenuename ("Apkplug"); o Ks.setvenuedescription ("Apkplug is the modular framework under Android!"); o Ks.setlatitude (23.056081f); Oks.setlongitude (113.385708f); Oks.setdisablessowhenauthorize (false);

3. Call the SHARESDK component to share

Agent. STATSHARESDK (New Checkinitcallback () {@Overridepublic void onsuccess (Plugsharesdk sharesdk) {            // SHARESDK component has been installed and started to complete            //perform sharing function sharesdk.showshare (OKs);} @Overridepublic void onfailure (int errorno, String strMsg) {}});

Run Demo:






Reduce application volume based on Apkplug call SHARESDK component

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.