How to find last activity from which current activity is opened in android?

前端 未结 5 618
野性不改
野性不改 2020-12-05 09:46

I have one activity which can be open from more 4 or 5 different activity so i can find from which activity my current activity is called...

If any idea please help

5条回答
  •  佛祖请我去吃肉
    2020-12-05 09:53

    Put some extras to intent for the different- different activities

    eg:

    startActivity(new Intent(this, otherActivity.class).putExtra("from" , "previousActivity"));
    

    and get extras in the current activity as

    string act = getIntent().getStringExtra("from");
    

    so "act" will indicate you the calling Activity.

提交回复
热议问题