Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8899467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:51:50+00:00 2026-06-15T00:51:50+00:00

I have an activity, which is a singleTask: public class MyActivity extends Activity {

  • 0

I have an activity, which is a singleTask:

public class MyActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        System.out.printf("### MyAcitvity.onCreate: " + getIntent().getExtras());
    }

    @Override
    protected void onResume() {
        super.onResume();
        System.out.println("### MyActivity.onResume: " + getIntent().getExtras());
    }

    public void toNext(View v) {
        startActivity(new Intent(this, AaaActivity.class));
    }
}

and:

<activity android:name=".MyActivity" android:launchMode="singleTask" />

No it has been started, and it started another activity called AaaActivity.

public class AaaActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.aaa);
    }

    public void jumpToFirst(View v) {
        Intent intent = new Intent(this, MyActivity.class);
        intent.putExtra("aaa","bbb");
        startActivity(intent);
    }

}

In the later one, there is a button which will trigger the jumpToFirst method to start the first one, and pass a data pair aaa=bbb. Since MyActivity is singleTask, it won’t create a new one, instead, it will just back to the existing MyActivity instance.

My question is: how to get the passing extra data from AaaActivity in MyActivity?

You can see I have logged onCreate and onResume methods, but it prints null extra data.

11-16 08:44:17.833: INFO/System.out(5171): ### MyAcitvity.onCreate: null
11-16 08:44:19.417: INFO/System.out(5171): ### MyActivity.onResume: null
11-16 08:44:26.041: INFO/System.out(5171): ### MyActivity.onResume: null
11-16 08:44:28.897: INFO/System.out(5171): ### MyActivity.onResume: null
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:51:52+00:00Added an answer on June 15, 2026 at 12:51 am

    Try setting the launchMode type of your MyActivity as singleTop and then override the following method to look for the new intent:

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        //now getIntent() should always return the last received intent
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity which needs to modify the SharedPreferences. public class AddingEmail extends
I have an Activity which is resumed with @Override protected void onResume() { Log.v(TAG,
I have an activity which extends GLActivity class. I need to use FaceBook sdk
I have many Activity which need to override onKeyDown event as below: @Override public
i have a activity which extends ListActivity. The Layout contains some generic widget an
I have an Activity which extends ExpandableListActivity and which contains some Parent Groups and
I have an activity which extends MapActivity. But when I tap the map, the
I have an activity which extends MapActivity. After running the activity, the Google Map
I have an activity which extends PreferenceActivity. I'm loading preferences from the xml file.
I have an Activity which extends MapActivity (to show a MapView) and contains a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.