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 7572077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:50:02+00:00 2026-05-30T15:50:02+00:00

I am developing an app with three activities called Activity Ex1, Ex2 and Ex3.

  • 0

I am developing an app with three activities called Activity Ex1, Ex2 and Ex3. The Ex2 and Ex3 activities has No History = true flag manifest file.

Ex1 is the main activity

my app flow is Ex1<->Ex2-->Ex3

I will set some values in the Ex1 Activities when the app is loaded such as no of counting and setting values for some boolean values.

In the first launch it works correctly. After that I go to Ex1 to Ex2 and come back to Ex1 by using intent (because I have to pass values from Ex2 to Ex1), so that the activity Ex1 values are reset again it causes wrong calculation in my app.

My requirement is whenever I open the app in that time only no of counting to be increased and done other setting values. The counting variables and setting variables should not be changed/modified whenever I am moving between Ex1 to Ex2, Ex2 to Ex1. Those should be effected only when I open the app. How do I do this?

  • 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-05-30T15:50:04+00:00Added an answer on May 30, 2026 at 3:50 pm

    Here’s approach without using shared preferences. I havent tested this, but it should work…

    If i understand you correctly you switch between activities Ex1 and Ex2 like this:

    Intent intent = new Intent(getBaseContext(), Ex1.class);
    //you are probably putting some data in your intent like this:
    intent.putExtra("myData", myData);
    startActivity(intent);
    

    So when switching to another activity, you can put additional boolean flag saying that your activity was switched from another activity. So when switching to Ex1, put put this in your Ex2 (and possibly all other activities that switch to Ex1)

    Intent intent = new Intent(getBaseContext(), Ex1.class);
    intent.putExtra("switched", true);
    startActivity(intent);
    

    Then, just put following condition in your Ex1 activity, in place where you are setting data (typically onCreate method)

    //was activity switched to, or did application just start?
    //if "switched" key isnt set in your intent, this just returns false
    boolean wasActivitySwitchedTo = getIntent().getExtras().getBoolean("switched");
    if(!wasActivitySwitchedTo) {
    //application started - **do your value setting here**
    ...
    } else {
    //activity was switched to from another activity - **dont do your setting**
    ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an android app that has a bunch of screens (activities) that are
Now I'm developing a Windows Phone 7 app, my app has three buttons located
The app I am developing has many activities organized into seven java packages. Originally
I am developing a windows app in c#. I have used three decimal variables:
I´m currently developing a Struts2 app where a user will make one of three
I have an app with 2 activities, the preference and the main activity, I
I'm developing a Windows Phone app. I have three pages, P1, P2 and P3.
I'm developing a web app and i want to auto resize three columns divs
I am developing an Android app with fragments that has many possible flows. With
I'm developing an app that must show one of three shapes(UIImageViews) depending on which

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.