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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:45:37+00:00 2026-06-05T09:45:37+00:00

I have following 2 activities(plus many more not important for this question): <activity android:name=.activities.HomeActivity

  • 0

I have following 2 activities(plus many more not important for this question):

<activity android:name=".activities.HomeActivity" android:excludeFromRecents="true" />
<activity android:name=".activities.AdHocActivity" android:noHistory="true"/>  

HomeActivity is a first one and only one wich I keep history for. User can go differnt places from Home and click Back to come back to main HomeActivity.

I also have service running on alarm and checking for some specific things. When specific criteria met I’m displaying my AdHocActivity

Intent i = new Intent(context, AdHocActivity.class);
                i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                i.putExtra(BlockingActivity.INTENT_BLOCKED_PACKAGE_NAME, packageName);
                context.startActivity(i);

FLAG_ACTIVITY_NEW_TASK was necessary to show Activity from BroadcastReceiver

Now, this AdHoc activity displays some message to user and has a button to take user back to HomeActivity

private void sendToMainApplication()
    {
        Intent i = new Intent(this, HomeActivity.class);
        startActivity(i);
        finish();
    }

All this work, but I get second instance of HomeActivity in a stack. So now when user taps “Back” – my Home activity flashes and comes back (previous copy).

I want only one copy to stay on top. I want it to be like anchor one. If it doesn’t exist – I want new one to be opened.

  • 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-05T09:45:39+00:00Added an answer on June 5, 2026 at 9:45 am

    The trick to prevent HomeActivity from being doubled was to call it like this:

    private void sendToMainApplication()
        {
            Intent i = new Intent(this, HomeActivity.class);
            i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(i);
            finish();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following model: activity_types: id, name activities: id, id_activity_type, occurrences, date (other
I have an app that goes between many different activities. One activity, my main
I have the following View setup in one of my Activities: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/photoLayout
I have seen the following two examples of starting activities in Android: Example 1
I have an Android App with 2 activities. I have the following in the
I have a lot of long-running activities and think that spawning this activity off
I have the following code in a few activities and it reads and parses
I have the following layout defined for one of my Activities: <?xml version=1.0 encoding=utf-8?>
I have following databases: test table1 fields: id, password, name, lastname test2 table2 fields:
I have the following code: $query = mysql_query(SELECT * FROM activity ORDER BY activity_time

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.