反应原生android moveTaskToBack? [英] React native android moveTaskToBack?
问题描述
React Native 中有没有像 moveTaskToBack
这样的库?
Is there any library which has ability like moveTaskToBack
in React Native?
以前我使用 https://github.com/jaysoo/react-native-activity-android 并且它有 moveTaskToBack
.但不幸的是,这个 repo 不再处于活动状态,并且自 React Native 0.29 以来,它有一些内部更改,使该库无法正常工作.
Previously I use https://github.com/jaysoo/react-native-activity-android and it has moveTaskToBack
. But unfortunately this repo is not active anymore, and since React Native 0.29, it has some internal change which make that library didn't work.
推荐答案
我不确定这是否是您需要的,但如果您将其放在 MainActivity.java 类中:
I'm not sure it's what you need, but if you put this in your MainActivity.java class:
@Override
public void invokeDefaultOnBackPressed() {
// do not call super.invokeDefaultOnBackPressed() as it will close the app. Instead lets just put it in the background.
moveTaskToBack(true);
}
然后当用户在根"页面上按下 android 后退按钮时,应用程序将进入后台而不是被关闭.
Then when user press the android back button on the "root" page, the app will go in background instead of being closed.
这篇关于反应原生android moveTaskToBack?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!