I need to finish an android application. For that i wrote
@Override
public void onBackPressed() {
AlertDialog.Builder builder = new AlertDialog.Builder(
Please read first this post from Google Android Developer Advocate Reto Meier : When to Include an Exit Button in Android Apps (Hint: Never)
What is th symptom that make you want to add an exit button ? If you need to clear the activity stack and always restart with a specific Activity, maybe you just have to tweak your activity manifest declaration with attributes like : android:clearTaskOnLaunch