Is there still a native.requestExit() API for Android?

Awhile ago i had come across a forum post somewhere about a API to close APP down all the way (not just suspending it) for Android Devices Only. its actually noted in Daily Build Release notes for build 623

http://developer.coronalabs.com/release/2011/623/

native.requestExit()

one of my apps just got rejected from Nook because it dint suspend right (and in this case i was using this command to just exit the app on a suspend) but now i am looking in the new API doc’s and it seems this doesn’t exist anymore?

or is there a new command to do this?

[import]uid: 88147 topic_id: 30377 reply_id: 330377[/import]

Yes, [lua]native.requestExit()[/lua] is still supported. We just haven’t documented it yet. That function will dismiss the Corona app the correct way. You should *never* call [lua]os.exit()[/lua] in your code because that will force quit your app in a not-so-nice way, and from an app reviewer’s standpoint, it will look like a crash when observing the Android log. [import]uid: 32256 topic_id: 30377 reply_id: 121717[/import]

Good to know, however I dont seem to get the application to properly “Exit” when triggering this command on a Nook Tablet (Not to be confused with a Nook Color it is a slightly different model) . Here is the code i am calling on suspend.

the Nook is supposed to suspend after 2 mins, which it does on my device. the screen will go black at the 2 min mark. so when i turn the device back on i am expecting my app to have to startup from scratch again (with the splash screen and all) but it doesn’t. it resumes right where the screen went black at. hence the request Exit didn’t seem to trigger?

[lua] platformOS = system.getInfo(“platformName”)
print("Platform Type: ",platformOS)
if( event.type == “applicationSuspend” ) then
if platformOS == “android” then
native.requestExit() – This is a new proper shutdown for Android OS ONLY, and works in daily build 623 or newer.
end
end[/lua] [import]uid: 88147 topic_id: 30377 reply_id: 121718[/import]

The function is named “request” exit for a reason. It is an exit request that is queued onto the Corona activity window’s message queue to be handled when that window is ready for it. The problem here is that you are requesting an exit when the operating system has already told the window to suspend. So it’s too late to request this exit.

A better way to handle this would be to override the Back key event and trigger a request exit there, while your app is still active. Although, I’m not sure if this is what you want.

Let me explain how the “n” key works on Nook. If your app is not displaying a status bar, then the “n” key on the Nook device is treated like a Back key, which will exit your app. However, if your app is displaying a status bar, then the “n” key is treated like a Home key and will suspend your app instead. It’s an odd behavior difference, but that’s just how Nook works.

So, I’m guessing your app is displaying the status bar. A simple solution would be to hide it. [import]uid: 32256 topic_id: 30377 reply_id: 121724[/import]

Thanks for the description on how that button behaves it does help me understand how the nook is using that button.

however… My code above does work with 1 minor change:

[lua] platformOS = system.getInfo(“platformName”)
print("Platform Type: ",platformOS)
if( event.type == “applicationSuspend” ) then
if platformOS == “Android” then --Notice i now have Android spelled with a capitol A
native.requestExit()
end
end[/lua]

This does cause my app to completely close now when the device is left on and idle for over 2 minutes. when the device auto suspends, my app does completely close out. And it also completely closes the app when they hit the nook ‘n’ button as well.

So now another problem i have been looking for a answer to…

how do i properly create a Rate this app link for the NOOK store that they wont reject the app for :slight_smile: [import]uid: 88147 topic_id: 30377 reply_id: 121828[/import]

Wow, okay, I didn’t think that would work. I’m glad you proved me wrong. :slight_smile:
And I’m sorry I didn’t notice the missing capital ‘A’ either. Guess we’re both guilty of that.

Regarding a “Rate this App” solution, currently there is no way to do this in Corona. But that said, it is a highly demanded feature and it is on our to-do list (no ETA yet). Even Barnes & Noble bugs us (and me) about this. [import]uid: 32256 topic_id: 30377 reply_id: 121891[/import]

Well even though i already have 1 app in the nook store with this code…(its been in thier store for months)

Apparently they reject apps that purposely shutdown on a suspend even. So …Even though this did work the way i wanted it to… Don’t Do It… :slight_smile:

“Files: Rejected: Your application exits when the devise is suspended.” ~nook

[import]uid: 88147 topic_id: 30377 reply_id: 121989[/import]

Good to know. Thanks for sharing. [import]uid: 32256 topic_id: 30377 reply_id: 122065[/import]

Yes, [lua]native.requestExit()[/lua] is still supported. We just haven’t documented it yet. That function will dismiss the Corona app the correct way. You should *never* call [lua]os.exit()[/lua] in your code because that will force quit your app in a not-so-nice way, and from an app reviewer’s standpoint, it will look like a crash when observing the Android log. [import]uid: 32256 topic_id: 30377 reply_id: 121717[/import]

Good to know, however I dont seem to get the application to properly “Exit” when triggering this command on a Nook Tablet (Not to be confused with a Nook Color it is a slightly different model) . Here is the code i am calling on suspend.

the Nook is supposed to suspend after 2 mins, which it does on my device. the screen will go black at the 2 min mark. so when i turn the device back on i am expecting my app to have to startup from scratch again (with the splash screen and all) but it doesn’t. it resumes right where the screen went black at. hence the request Exit didn’t seem to trigger?

[lua] platformOS = system.getInfo(“platformName”)
print("Platform Type: ",platformOS)
if( event.type == “applicationSuspend” ) then
if platformOS == “android” then
native.requestExit() – This is a new proper shutdown for Android OS ONLY, and works in daily build 623 or newer.
end
end[/lua] [import]uid: 88147 topic_id: 30377 reply_id: 121718[/import]

The function is named “request” exit for a reason. It is an exit request that is queued onto the Corona activity window’s message queue to be handled when that window is ready for it. The problem here is that you are requesting an exit when the operating system has already told the window to suspend. So it’s too late to request this exit.

A better way to handle this would be to override the Back key event and trigger a request exit there, while your app is still active. Although, I’m not sure if this is what you want.

Let me explain how the “n” key works on Nook. If your app is not displaying a status bar, then the “n” key on the Nook device is treated like a Back key, which will exit your app. However, if your app is displaying a status bar, then the “n” key is treated like a Home key and will suspend your app instead. It’s an odd behavior difference, but that’s just how Nook works.

So, I’m guessing your app is displaying the status bar. A simple solution would be to hide it. [import]uid: 32256 topic_id: 30377 reply_id: 121724[/import]

Thanks for the description on how that button behaves it does help me understand how the nook is using that button.

however… My code above does work with 1 minor change:

[lua] platformOS = system.getInfo(“platformName”)
print("Platform Type: ",platformOS)
if( event.type == “applicationSuspend” ) then
if platformOS == “Android” then --Notice i now have Android spelled with a capitol A
native.requestExit()
end
end[/lua]

This does cause my app to completely close now when the device is left on and idle for over 2 minutes. when the device auto suspends, my app does completely close out. And it also completely closes the app when they hit the nook ‘n’ button as well.

So now another problem i have been looking for a answer to…

how do i properly create a Rate this app link for the NOOK store that they wont reject the app for :slight_smile: [import]uid: 88147 topic_id: 30377 reply_id: 121828[/import]

Wow, okay, I didn’t think that would work. I’m glad you proved me wrong. :slight_smile:
And I’m sorry I didn’t notice the missing capital ‘A’ either. Guess we’re both guilty of that.

Regarding a “Rate this App” solution, currently there is no way to do this in Corona. But that said, it is a highly demanded feature and it is on our to-do list (no ETA yet). Even Barnes & Noble bugs us (and me) about this. [import]uid: 32256 topic_id: 30377 reply_id: 121891[/import]

Well even though i already have 1 app in the nook store with this code…(its been in thier store for months)

Apparently they reject apps that purposely shutdown on a suspend even. So …Even though this did work the way i wanted it to… Don’t Do It… :slight_smile:

“Files: Rejected: Your application exits when the devise is suspended.” ~nook

[import]uid: 88147 topic_id: 30377 reply_id: 121989[/import]

Good to know. Thanks for sharing. [import]uid: 32256 topic_id: 30377 reply_id: 122065[/import]