Skip to content

Commit 60f8937

Browse files
committed
Update host-inject documentation
1 parent 388147f commit 60f8937

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

docs-source/src/en/api/special-features/host-inject.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,28 @@ val context: Context = ... // Assume this is your Context
193193
context.startActivity(context, HostTestActivity::class.java)
194194
```
195195

196+
The `proxy` parameter we set in the `registerModuleAppActivities` method above is the default global proxy `Activity`.
197+
198+
If you need to specify a delegated `Activity` to use another Host App's `Activity` as a proxy, you can refer to the following method.
199+
200+
> The following example
201+
202+
```kotlin
203+
class HostTestActivity : ModuleAppActivity() {
204+
205+
// Specify an additional proxy Activity class name
206+
// Which must also exist in the Host App's AndroidManifest
207+
override val proxyClassName get() = "com.demo.test.activity.OtherActivity"
208+
209+
override fun onCreate(savedInstanceState: Bundle?) {
210+
super.onCreate(savedInstanceState)
211+
// Module App's Resources have been injected automatically
212+
// You can directly use xml to load the layout
213+
setContentView(R. layout. activity_main)
214+
}
215+
}
216+
```
217+
196218
::: tip
197219

198220
For more functions, please refer to the [Context.registerModuleAppActivities](../public/com/highcapable/yukihookapi/hook/factory/YukiHookFactory#context-registermoduleappactivities-ext-method) method.

docs-source/src/zh-cn/api/special-features/host-inject.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,26 @@ val context: Context = ... // 假设这就是你的 Context
186186
context.startActivity(context, HostTestActivity::class.java)
187187
```
188188

189+
上面我们在 `registerModuleAppActivities` 方法中设置的 `proxy` 参数为默认的全局代理 `Activity`
190+
191+
如果你需要指定某个代理的 `Activity` 使用另外的宿主 `Activity` 进行代理,你可以参考如下方法。
192+
193+
> 示例如下
194+
195+
```kotlin
196+
class HostTestActivity : ModuleAppActivity() {
197+
198+
// 指定一个另外的代理 Activity 类名,其也必须存在于宿主的 AndroidManifest 中
199+
override val proxyClassName get() = "com.demo.test.activity.OtherActivity"
200+
201+
override fun onCreate(savedInstanceState: Bundle?) {
202+
super.onCreate(savedInstanceState)
203+
// 模块资源已被自动注入,可以直接使用 xml 装载布局
204+
setContentView(R.layout.activity_main)
205+
}
206+
}
207+
```
208+
189209
::: tip
190210

191211
更多功能请参考 [Context.registerModuleAppActivities](../public/com/highcapable/yukihookapi/hook/factory/YukiHookFactory#context-registermoduleappactivities-ext-method) 方法。

0 commit comments

Comments
 (0)