How to differentiate From Which Activity the curre

2019-03-01 02:46发布

Form Activity Login I call

Intent intent=new Intent(LogIn.this,BRInfoActivity.class);

From Activity BrActivityList I Call

Intent intent=new Intent(BRActiviList.this, BRInfoActivity.class);
intent.putExtra("BRinfo", objBR);

And Now in BRInfoActivityList

Intent i = getIntent();
BrInfoEN objBR=(BrInfoEN)i.getSerializableExtra("BRinfo");

Now i want if(intent==BrActivityList)The last two above line execute otherwise does not.How to do it?

3条回答
贪生不怕死
2楼-- · 2019-03-01 03:33

Form Activity Login call this--

Intent intent=new Intent(LogIn.this,BRInfoActivity.class);
intent.putExtra("call_from","ActivityClass");

From Activity BrActivityList Call--

Intent intent=new Intent(BRActiviList.this, BRInfoActivity.class);
intent.putExtra("call_from", "BRActivity");

Now, when you get the intent, compare the "call_from" string in an if-else block! That's it!

查看更多
做自己的国王
3楼-- · 2019-03-01 03:33

If you will start activity with startActivityForResult(). Then you can use getCallingActivity() to get caller.

查看更多
冷血范
4楼-- · 2019-03-01 03:48

May this help you...

The new intent comes as part of onNewIntent(Intent). The original Intent is still available via getIntent().

You put whatever code you need to into onNewIntent in order to update the UI with the new parameters; probably similar to what you're doing in onCreate.

Also, you probably want to call setIntent(intent) in onNewIntent to make sure future calls to getIntent() within the Activity lifecycle get the most recent Intent data.

查看更多
登录 后发表回答