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

  • Home
  • SEARCH
  • 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 9253571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:15:09+00:00 2026-06-18T11:15:09+00:00

I start an activity A from B with an intent with extras and based

  • 0

I start an activity A from B with an intent with extras and based on the type of extra in onCreate I do some process and it works fine.

But when I do a orientation change the same old intent is re-delivered by the system to me and the whole process gets restarted since I go through the onCreate once again.

My code completely take care of restoring the previous state of the activity when the onCreate gets called if no old intent is delivered to it. But since the system re-delivers it make my activity think it is a new intent and restarts the whole process once again.

I tried the flag intent.getFlags() != Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY. This flag prevents re-delivery in case of long press home button and activity launched from history but no effect on orientation change.

A dirty fix was proposed in another thread Dirty Fix but I am wondering if there is a proper way to address this problem.

Thanks in advance

  • 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-18T11:15:10+00:00Added an answer on June 18, 2026 at 11:15 am

    A ‘clean’ solution to this problem would be to use Fragments.

    Create your own Fragment subclass.
    In its onCreate, be sure to call setRetainInstance(true).
    In its onCreate you can start your process.
    If it is just for doing some work, return null in its onCreateView.

    In your Activity’s onCreate:
    – First try to find the current instance of your own Fragment.
    – If not found, create a brand new one and commit this to your Fragment Transaction.

    By calling setRetainInstance(true) and by first trying to find it before creating a new Fragment in the Activity’s onCreate, you keep the same Fragment instance even after a rotation and the Fragment’s onCreate won’t be called again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I 'clean' values from extra intent? Activity: @Override public void onCreate(Bundle savedInstanceState)
Good day, I try to start new Activity from another. But it always crashed.
Suppose you want to start a new activity and pass it some data from
I'm not able to start activity from thread. I want to start one activity
I am attempting to start an activity from the children of my expandable list
I have this situation where i have to start an activity from my mainActivity.
I am trying to start the main activity from inside a BroadcastReceiver. I dont
I try to start action with service (or activity) from an url. (with params)
As you can see from the documentation the way to start an Activity to
I would like to start a broadcast receiver from an activity. I have 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.