在 Android 中检测硬件后退按钮
BackAndroid.addEventListener('hardwareBackPress', function() {
if (!this.onMainScreen()) {
this.goBack();
return true;
}
return false;
});
注意:this.onMainScreen() 和 this.goBack() 不是内置函数,你还需要实现它们。 ( https://github.com/immidi/react-native/commit/ed7e0fb31d842c63e8b8dc77ce795fac86e0f712)