简体   繁体   中英

How to get Intent of main launch Activity from a different Activity?

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 ?

import android.os.Bundle;

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

Replace pics and getInt as needed.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM