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
Post a Comment