How to get Intent of main launch Activity from a d

2019-04-10 05:11发布

I'm currently in a different Activity. How can I get the main launch Activity's Intent?

Intent launchIntent = getIntent();

In the above, obviously getIntent() would not get me the correct Intent that I need.

How can I get the main launch Activity's Intent?

2条回答
贪生不怕死
2楼-- · 2019-04-10 05:49

When Activity1 loads, grab the Bundle associated with it's launch.

When Activity2 is launched, put these same extras into your new Intent, and pass it on to Activity2.

You can't just access an Intent from a different activity, you need to pass the information along.

查看更多
时光不老,我们不散
3楼-- · 2019-04-10 06:03
import android.os.Bundle;

Bundle extras = getIntent().getExtras();
   if (extras != null) {
       pics = extras.getInt(KEY_HERE);
   }

Replace pics and getInt as needed.

查看更多
登录 后发表回答