Application closing

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Application closing

Postby williamzanelli » Sat Jul 18, 2009 2:57 pm

Hi guys


Just wanted to know how to close my application, as in when a user presses the "back" button whilst the app is running, the application exits - so if you were to click on the application again, it would start again completely

However when you press the home button, whilst the app is running, and then were to click on the app icon, you enter teh app where you left off.

I want to "destroy" the app instance when a user clicks home or back. How could I achieve this?

Thanks for your thoughts
Will
williamzanelli
Experienced Developer
Experienced Developer
 
Posts: 63
Joined: Mon Jan 05, 2009 2:37 am
Location: UK

Top

Postby mangaluve » Sat Jul 18, 2009 3:26 pm

Call finish() from the Activity you want to close
mangaluve
Experienced Developer
Experienced Developer
 
Posts: 82
Joined: Mon Mar 23, 2009 8:59 pm

Postby williamzanelli » Sat Jul 18, 2009 4:31 pm

I have called finish it works if you press back, but if you press home - the activity is not destroyed.

I checked the log cats, the onKeyDown method is not called.

I identify the home key as - KeyEvent.KEYCODE_HOME

Any ideas why?
Will
williamzanelli
Experienced Developer
Experienced Developer
 
Posts: 63
Joined: Mon Jan 05, 2009 2:37 am
Location: UK

Postby mangaluve » Sat Jul 18, 2009 5:45 pm

Oh sorry, I misread your message :)

I don't know if there's a way to detect specifically if the HOME key has been pressed. I suppose onPause or something like that will trigger though. I think onUserLeaveHint() will trigger too.
mangaluve
Experienced Developer
Experienced Developer
 
Posts: 82
Joined: Mon Mar 23, 2009 8:59 pm

Postby williamzanelli » Sun Jul 19, 2009 1:52 pm

Thanks for the message.

Well actuually what happens, when you press "Home" is the on Pause gets called, but the KeyEvent method doesnt seem to be getting called.

Strange...!!

Somehow need to override something somewhere :( :(
Will
williamzanelli
Experienced Developer
Experienced Developer
 
Posts: 63
Joined: Mon Jan 05, 2009 2:37 am
Location: UK

Postby williamzanelli » Mon Jul 20, 2009 9:36 pm

Does anyopne have a solutuion to this prob?
Will
williamzanelli
Experienced Developer
Experienced Developer
 
Posts: 63
Joined: Mon Jan 05, 2009 2:37 am
Location: UK

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 6 guests