scheme: head://module/action?params={json}
#使用方法:
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'
依赖
<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>
@Module("xxx")
class MyTestDispatcher {
@Action("xxx")
fun testInvoke(context: Context?, params: String?, callback: Callback?) {
callback.call("{json}")
Log.e("MyTestDispatcher", "testInvoke${params}")
}
}