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

Categories

0 votes
179 views
in Technique[技术] by (71.8m points)

java - close an activity from other activity?

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

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

1 Answer

0 votes
by (71.8m points)
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
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...