Question

I have a registration form in android wherein the user can enter data from it. The user can search for Clinic. After that searching, the user submitted the record, and logout. If the user doesn't have no business with that app, the user can exit BUT when the user pressed the Exit button, it does not exiting, instead it goes to the Searching activity all over again even if the user is logout already. Can someone help me figure out why I can't finish my activity?

Search Activity

btn_Close.setOnClickListener(new OnClickListener() {
        public void onClick(View v)
        {
            Intent myIntent = new Intent(getApplicationContext(), RegForm.class);
            myIntent.putExtra("from", "Search_Cancel");

            startActivity(myIntent);
            Search.this.finish();
        }
    });

Android Manifest

    <activity
        android:name=".Search"
        android:noHistory="true" > 
    </activity>
Était-ce utile?

La solution 2

finish() will make your active Activity pop from the Back stack but your others Activities will remain on that so if you want to exit whole app you should use Flag FLAG_ACTIVITY_CLEAR_TOP when you are starting your Last Activity to Clear your Back Stack

Autres conseils

Activities are finished with the this.finishActivity(Activity.RESULT_OK); call.
Note: You may also specify other results located in the Activity class as static finals.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top