-1

I am trying to exit my application from my HOME button by calling finish() function. But, when I invoke finish(), the application is not exiting, but is going to close the previous activity. What should I do to resolve this? Thank you.

Alberto Solano
  • 7,972
  • 3
  • 38
  • 61
alanvabraham
  • 779
  • 2
  • 14
  • 25
  • Read this question of SO --> http://stackoverflow.com/questions/2033914/quitting-an-application-is-that-frowned-upon and this page: http://groups.google.com/group/android-developers/browse_thread/thread/4c1b8955ebfd5799 – Alberto Solano Dec 31 '11 at 11:03

4 Answers4

0

call moveTaskToBack(true) on your Activity (it doesn't kill your app but remove it from screen)

surfealokesea
  • 4,971
  • 4
  • 28
  • 38
0

when you want to close your application, you can call

  finishAffinity();

or if you want close it in background also you should write,

  android:excludeFromRecents="true"

in AndroidManifest :

   <activity
    android:name="com.smart.remote.main.SplashActivity"
    android:configChanges="orientation|keyboardHidden"
    android:screenOrientation="portrait" 
    android:excludeFromRecents="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
elifekiz
  • 1,456
  • 13
  • 26
0
moveTaskToBack(true); 

will move your application to background!

Ahmad Vatani
  • 1,630
  • 4
  • 21
  • 34
0

That's to be expected finish() only closes the current activity, but since all the activities launched are kept in an activity stack, the previously opened activity shows up. You can read more about this here: http://developer.android.com/guide/practices/ui_guidelines/activity_task_design.html#navigating_away_from_an_activity

asenovm
  • 6,397
  • 2
  • 41
  • 52