React Native:BackHandler.exitApp()无法杀死应用程序的进程

时间:2017-06-22 08:40:09

标签: react-native

当我看到本机代码时。

var index=0 forAll { (a: Int, b: Int) => someBehavior(index,FunArgs1(a, b)) index = index+1 } 会调用android BackHandler.exitApp()

为什么不调用onBackPressed()退出应用并终止进程?

2 个答案:

答案 0 :(得分:0)

  

为什么不调用System.exit(0)退出应用程序并终止进程?

System.exit(0)是一种破坏申请流程的糟糕方法。 Android以极好的风格管理它。这使他们打电话给onBackPressed()

答案 1 :(得分:0)

您可以使用react-native-exit-app
并将BackHandler.exitApp()替换为:

import RNExitApp from 'react-native-exit-app'; ... RNExitApp.exitApp(); ...