PDA

View Full Version : Sencha Touch 2.1.0 in native app format,how to show a confirm dialog before app exits



liduqun
19 Nov 2012, 7:58 PM
I have package touch app to android native app format,I want to show a query dialog before the app will exit,and if the use answer no,I want to abort the quiting process(then the app remaind running).
How should I do ?
thanks!

AndreaCammarata
26 Nov 2012, 6:43 AM
I'm sorry but you can't!
This is not a ST related issue, but you would have the same problem developing a native iOS / Android app.
Eventually you could detect when an app execution has been set in background mode, but nothing more, if you try to think, have you ever seen an app asking yourself if you really want to quit using an hardware button?

Hope this helps.

ingo.hefti
27 Nov 2012, 11:55 PM
I'm sorry but you can't!
This is not a ST related issue, but you would have the same problem developing a native iOS / Android app.
Eventually you could detect when an app execution has been set in background mode, but nothing more, if you try to think, have you ever seen an app asking yourself if you really want to quit using an hardware button?
I have to disagree! It may not be possible for iOS (no hw back button), but certainly for Android. Only ST2.1 doesn't have support for the BACK button in a native packaged app. So for the time being one would have to use PhoneGap to do that.

AndreaCammarata
28 Nov 2012, 12:11 AM
I have to disagree! It may not be possible for iOS (no hw back button), but certainly for Android. Only ST2.1 doesn't have support for the BACK button in a native packaged app. So for the time being one would have to use PhoneGap to do that.

Then you should have asked:
"Is it possible to intercept the back button on Android?"

Don't forget that the user can quit an app using the Home button on Android too and even in this case, it's not possible to intercept the event to display a warning message as you requested.

The best you can do in this case is intercept the onStop(), onPause() and onDestroy() events to perform some application actions before the app close but this doesn't solve your problem anyway.

ingo.hefti
28 Nov 2012, 12:43 AM
Then you should have asked:
"Is it possible to intercept the back button on Android?"
Your point! ;)

However, being an Android kid, it was quite obvious to me what he was talking about. Because today this is one of the BIG drawbacks for native Android apps done with ST. Android users are so much used to the HARDWARE BACK button that they are constantly using it. And for ST apps that means every time: quit the app... which is real bad!

AndreaCammarata
28 Nov 2012, 12:57 AM
Your point! ;)

However, being an Android kid, it was quite obvious to me what he was talking about. Because today this is one of the BIG drawbacks for native Android apps done with ST. Android users are so much used to the HARDWARE BACK button that they are constantly using it. And for ST apps that means every time: quit the app... which is real bad!

That's your point of view! :)

"show a query dialog before the app will exit" !== detect back button

However, just to be clear:
- Using the Sencha native, at the moment, is not possible to intercept the back button. You can using PhoneGap.
- If you want to detect the application exit and display a warning message which avoids the app to close it's impossible using both.