Skip to content

leeyuanxia/schemeutil

Repository files navigation

scheme: head://module/action?params={json}

#使用方法:

1。在android的module的build.gradle 中引入

plugin  id 'kotlin-kapt'

和在

android {
    defaultConfig {
        ...
        javaCompileOptions {
            annotationProcessorOptions {
            arguments = [SCHEME_MODULE_NAME: project.getName(), SCHEME_GENERATE_DOC: "enable"]
            }
        }
    }
}

加入

implementation 'xxx.xxx.xxx.schemeutils:schemeutil:VERSION@aar'
implementation 'xxx.xxx.xxx.schemeutils:IDispatchers:VERSION@aar'
implementation 'xxx.xxx.xxx.schemeutils:constant:VERSION@jar'
implementation 'xxx.xxx.xxx.schemeutils:lib-processor:VERSION'
kapt 'xxx.xxx.xxx.schemeutils:lib-processor:VERSION'
implementation 'xxx.xxx.xxx.schemeutils:lib-annotation:VERSION@jar'

依赖

2。在application oncreate的时候调用SUInit.init(this);

3。在app的mainfest中添加

<activity
    android:name="xxx.xxx.xxx.SchemeDispatcherActivity"
    android:exported="true"
    android:theme="@style/TestTheme">
    <intent-filter>
        <!-- action.VIEW和category.DEFAULT必须设置 -->
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <!-- 如果需要浏览器支持打开,则category.BROWSABLE -->
        <category android:name="android.intent.category.BROWSABLE" />
            <!-- schema的协议类型:随便设置,只要按照统一规则,前后端一致就行 -->
            <data android:scheme="xxx" />
    </intent-filter>
</activity>

4。使用demo:

@Module("xxx")
class MyTestDispatcher {
    @Action("xxx")
    fun testInvoke(context: Context?, params: String?, callback: Callback?) {
        callback.call("{json}")
        Log.e("MyTestDispatcher", "testInvoke${params}")
    }
}

5。注意:@Module中的value具有唯一性,只能在一个代码文件中定义

About

一个模仿ARouter,使用scheme机制实现的安卓应用内,H5和安卓应用的跳转交互框架。使用注解将业务逻辑和底层scheme跳转管理相解耦,使得业务开发能够专注于业务逻辑。安卓跳转交互框架

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors