M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Quit an app - programmatically

hi,

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

Thanks,
M&M

Louis
Posts: 0
Joined: Wed Nov 05, 2014 2:03 pm

Quit an app - programmatically

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.

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Quit an app - programmatically

hi,

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

Thanks,
M&M

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Quit an app - programmatically

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

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Quit an app - programmatically

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
}

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Quit an app - programmatically

Hello!

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

Return to “Issues”