Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
165 views
Welcome To Ask or Share your Answers For Others

1 Answer

First Go to parent activity by starting it
@Override
 protected void onActivityResult(int requestCode, int resultCode, Intent intent)
{
super.onActivityResult(requestCode, resultCode, intent);
switch(Code){
 case A: go to that activity and finsih() this again come back to parent activity
 case B: go to that activity and finsih() this again come back to parent activity
/////and son on
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...