Page 1 of 1

Quit an app - programmatically

Posted: Fri Nov 14, 2014 9:59 am
by M&M

hi,

I have a "Quit" button in my app. How do I close the app upon clicking the button?

Thanks,
M&M


Quit an app - programmatically

Posted: Fri Nov 14, 2014 10:04 am
by Louis

I think for Android it's codenavigator.app.exitApp();/code

As far as I know for iOS, you're not allowed to close it programmatically. You are forced to use the home button.


Quit an app - programmatically

Posted: Fri Nov 14, 2014 10:26 am
by M&M

hi,

right but then how do I determine programmatically whether it is android or iOS?

Thanks,
M&M


Quit an app - programmatically

Posted: Fri Nov 14, 2014 10:58 am
by M&M

hi,

the reason is that navigator.app.exitApp(); works only in android. So i want to check if the OS is android then execute that command, otherwise will do nothing.

Thanks,
M&M


Quit an app - programmatically

Posted: Fri Nov 14, 2014 11:19 am
by M&M

This works

var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() isMobile.BlackBerry() isMobile.iOS() isMobile.Opera() isMobile.Windows());
}

Code: Select all

 }; 

if ( isMobile.Android() ) {
// Do whateva you wana do :-D
}


Quit an app - programmatically

Posted: Fri Nov 14, 2014 12:57 pm
by Maryna Brodina

Hello!

Just execute the following code prenavigator.app.exitApp();/pre