How to find back stack activities in an android application?

后端 未结 7 2162
不思量自难忘°
不思量自难忘° 2020-12-24 13:59

I have an application with activities back stack A -> B -> C -> D -> E. Now at activity E, I want to know the back stack activities that I navigated from. How do I find this

7条回答
  •  星月不相逢
    2020-12-24 14:18

    I recommend you to utilize startActivityForResult instead of startActivity, then in order to retrieve the origin/source activity- call getCallingActivity().getClassName().

    How will A know it came from home? Use getIntent() its

    getAction() -> android.intent.action.MAIN

    and

    getCategories() -> android.intent.category.LAUNCHER

提交回复
热议问题