-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App can't exit #2540
Comments
What kind of problems do you have? It's not clear only after reading post title and looking to your code. |
Please, try to wrap your full code for better reading. But from what I am getting - this might be an issue with |
yes,i have the issue. |
I have the same issue, here is my router
When i'm at my reset scenes, nothing happened when i touch the physical android button, but when im at my normal scenes, the app will exit if i press the physical back button. |
@sitompul I have the exact same issue! Did you find a fix for this? I am planning to use an older version instead but I dont intend to do that. I like the platform specific overrides of Screen to Screen nav animation! And what version of RN are you using? Mine is 0.50.4. Also my RNRF version is the same as yours. |
Any update on this issue?? Even I'm getting this on 4.0.0-beta.24 |
@rajeshbatth-gommt @nishiltamboli look for @Blapi 's comment at #2737 |
Please check Example project - I checked hardware back and it works fine. |
i have solved the problem; |
Version
Tell us which versions you are using:
class Example extends Component {
constructor(props) {
super(props);
this.state = {
isFirstIn: false,
isLoading: true
}
}
componentWillMount(){
BackHandler.addEventListener('hardwareBackPress', this.handleBackButton);
this.setState({
isLoading: false,
isFirstIn: false
});
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton);
}
handleBackButton = () => {
// PublicToast.showMessage('_onExitApp'); // 在不传 backAndroidHandler 有 onExitApp 时调用
this._exit();
}
// 退出程序
_exit = () => {
// 当前页面为root页面时的处理
if (this.lastBackPressed && (this.lastBackPressed + 2000 >= Date.now())) {
//最近2秒内按过back键,可以退出应用。
//alert 亲,你真的要离开我吗
BackHandler.exitApp();
return true;
}
this.lastBackPressed = Date.now();
alert('再按一次退出应用');
return true;
};
render() {
if (this.state.isLoading == true) {
return (
<View style={{flex: 1, backgroundColor: 'white',alignItems:'center',justifyContent:"center"}}>
)
} else {
return (
<Modal
hideNavBar
transitionConfig={() => ({screenInterpolator: CardStackStyleInterpolator.forFadeFromBottomAndroid})}
>
<Stack
hideNavBar
key="root"
titleStyle={{alignSelf: 'center'}}
>
<Scene key="echo" back clone component={EchoView} getTitle={({navigation}) => navigation.state.key}/>
}
}
The text was updated successfully, but these errors were encountered: