Does anyone know how to close an activity from other activity?? for example: i have 3 activity (activity A, B, and C) and from activity C, i can close an activity A.. my activity structure is activity A -> activity B -> activity C how to close an activity A from activity C?
i was try this code :
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent goToLockScreen= new Intent(this,LockScreenForm.class);
startActivity(goToLockScreen);
finish();
but that code is only fot closing activity A from activity B, and can't close activity A from activity C direcly..
Does anyone know about closing an activity direcly from other activity?? thanks..
try this
If the update activity is launching another installation activity, then you may want to override void onActivityResult(int requestCode, int resultCode, Intent intent) in the update activity, providing the following implementation. Also, when the update activity launches the installation activity, it should do so with startActivityForResult(Intent, int), not with startActivity(Intent).
What about starting both B and C
forResult
and send a result back to pervious activity to let A finally callfinish()
? Like this:A
startActivityForResult()
-> BstartActivityForResult()
-> CC
setResult()
-> BonActivityResult(){setResult()}
-> ConActivityResult(){finish()}
Sounds complicated, but maybe it can be used as a workaround?
This is a prescribed way and you should follow it.. if you want some other behaviour yo can implement it.. there are lot many questions asked on this topic.. refer other questions...
try It work perfectly for me
Now You have to finish Activity-A from Activity-B
Activity-B or 2nd Activity