Possible Duplicate:
android pressing back button should exit the app
I'm building a register and login screen just for an exercise. So I put SharedPreferences so that when user open the app again, it will direct them to login activity and not start again from register. However, when I press back button from login activity it still take me back to register activity which could change the already saved SharedPreferences. I wanna disable this function, how to simply exit the app when user press the back button?
Thanks,
If you never want the back button to return to the registration screen, the cleanest solution would be to exclude it from the activity history using the noHistory
attribute in the manifest, i.e.
<activity
android:name=".RegistrationActivity"
...
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>