GithubHelp home page GithubHelp logo

twspluginframework's Introduction

# TwsPluginFramework插件框架

TwsPluginFramework(下面简称TPF框架)能很好的解决大中项目团队的队协作问题,实现模块解耦、并行开发、模块动态更新,适用于Android 4.3以上系统版本的应用开发。


**开始使用TwsPluginFramework框架**

- [1. 使用TPF框架](#1)
- [2. 非独立插件应用配置](#2)

## 1. 使用TPF框架
	Step 1. clone工程到本地
		【其实你只需要里面的sdk】

	Step 2. 引用twsplugincore.jar
		然后将sdk目录下面的twsplugincore.jar引用到工程里面,同时将主工程的Application继承PluginApplication。
	
	Step 3. 配置AndroidManifest.xml【这里以TwsPluginHost为案例】
		①、配置两个框架需要的Provider:

		<!-- core -->
        <provider
            android:name="com.tws.plugin.manager.PluginManagerProvider"
            android:authorities="com.tencent.tws.pluginhost.manager"
            android:exported="false" />
        <provider
            android:name="com.tws.plugin.servicemanager.ServiceProvider"
            android:authorities="com.tencent.tws.pluginhost.svcmgr"
            android:exported="false" />

		②、然后申明预备的组件Receiver(注册1个即可)、service[配置多个,同时需要配置多个不同进程的]、activity[配置多个、同时需要配置多个不同Mode的],框架通过action来查询。
			普通组件的规则:
		    <intent-filter>
                <action android:name="com.tencent.tws.pluginhost.STUB_DEFAULT" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
	
			独立进程Service组件的申明规则:
			<intent-filter>
                <action android:name="com.tencent.tws.pluginhost.MP_STUB_DEFAULT" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
			*独立进程Service的进程名配置规则:android:process=":plugin【 + 后缀(建议用数字)】"

		③、配置工程中显示插件fragment的容器:			
        	<!-- 要展示插件中的fragment -->
        	<activity
            	android:name=".plugindebug.PluginFragmentActivity"
            	android:screenOrientation="portrait" />
       		<!-- 要展示插件中的(Tws)fragment -->
        	<activity
            	android:name=".plugindebug.PluginTwsFragmentActivity"
            	android:screenOrientation="portrait" /> 

## 2. 非独立插件应用配置
	Step 1. 指定宿主包名
		插件如果要使用宿主的共享功能(代码/资源),需要显示的指定宿主包名,这样框架就会在构建插件的ClassLoader和Resources的时候就会将宿主的构建进插件里面。

		android:sharedUserId="com.tencent.tws.pluginhost"

	Step 2. 配置可见的fragment
		<!-- 通知插件框架哪些fragment是可以嵌入宿主Activity的,如果fragment只是插件内使用,无需对外暴露则无需配置 -->
        <exported-fragment
            android:name="some_id_for_fragment3"
            android:value="com.example.plugindemo.fragment.PluginSpecTwsFragment" />

twspluginframework's People

Contributors

rickdynasty avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.