Skip to content

Commit

Permalink
docs(android): update doc and example for BackAndroid (#3325)
Browse files Browse the repository at this point in the history
Co-authored-by: OpenHippy <124017524+open-hippy@users.noreply.github.com>
  • Loading branch information
iPel and open-hippy authored Jun 28, 2023
1 parent 5d05b0d commit e85ecfc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/api/hippy-react/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ AsyncStorage 是一个简单的、异步的、持久化的 Key-Value 存储系

可以监听 Android 实体键的回退,在退出前做操作或拦截实体键的回退。 `hippy-react-web` 不支持。

> 注意:该方法需要终端拦截实体返回按钮的事件,可以参考 [android-demo 的 onBackPressed 方法](//github.com/Tencent/Hippy/blob/master/examples/android-demo/example/src/main/java/com/tencent/mtt/hippy/example/MyActivity.java)
> 注意:该方法需要终端拦截实体返回按钮的事件,可以参考 [android-demo 的 onBackPressed 方法](//github.com/Tencent/Hippy/blob/v3.0-dev/framework/examples/android-demo/src/main/java/com/openhippy/example/PageConfiguration.kt)
## 方法

Expand Down
2 changes: 1 addition & 1 deletion docs/api/hippy-vue/vue-native.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Vue.Native.AsyncStorage.getItem('itemKey');
可以监听 Android 实体键的回退,在退出前做操作或拦截实体键的回退。

>* 最低支持版本 2.7.0
>* 注意:该方法需要终端拦截实体返回按钮的事件,可以参考 [android-demo 的 onBackPressed 方法](//github.com/Tencent/Hippy/blob/master/examples/android-demo/example/src/main/java/com/tencent/mtt/hippy/example/MyActivity.java)
>* 注意:该方法需要终端拦截实体返回按钮的事件,可以参考 [android-demo 的 onBackPressed 方法](//github.com/Tencent/Hippy/blob/v3.0-dev/framework/examples/android-demo/src/main/java/com/openhippy/example/PageConfiguration.kt)
## 方法

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ class PageConfiguration : AppCompatActivity(), View.OnClickListener {
}

override fun onBackPressed() {
buildSnapshot { moveTaskToBack(true) }
val goBack: () -> Unit = { buildSnapshot { moveTaskToBack(true) } }
hippyEngineWrapper?.apply {
if (hippyEngine.onBackPressed(goBack)) {
return
}
}
goBack()
}

private fun buildSnapshot(runnable: Runnable) {
Expand Down

0 comments on commit e85ecfc

Please sign in to comment.