How to finish multiple activities at once in android? -


i have activity flows activity -> activity b -> activity c -> activity d. when user on activity d , click button called exit, application should go activity b , finish activities c , d. how can that?

note : activity b , activity d same class different instance

in androidmanifest.xml, set android:nohistory true activity b, c , d. set false activity (actually, default false).

demo:

<activity android:name=".xx.xx.activitya"      android:nohistory="false"     android:screenorientation="nosensor"> </activity>  <activity android:name=".xx.xx.activityb"      android:nohistory="true"     android:screenorientation="nosensor"> </activity>          <activity android:name=".xx.xx.activityc"      android:nohistory="true"     android:screenorientation="nosensor"> </activity>  <activity android:name=".xx.xx.activityd"      android:nohistory="true"     android:screenorientation="nosensor"> </activity> 

for exit button:

exitbtn.setonclicklistener(new view.onclicklistener() {     @override     public void onclick(view v) {         intent intent = new intent(getapplicationcontext(),activityb.class);         startactivity(intent);         finish();     } }); 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -