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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:04:53+00:00 2026-06-11T09:04:53+00:00

First of all i give you a short example for my problem. Keep in

  • 0

First of all i give you a short example for my problem. Keep in mind that the wanted behavior of my app is for my own use only.

Lets say i have an app with one activity and some fragments. This app starts up through a static broadcastreceiver with an intent e.g. ACTION_POWER_CONNECTED. To this point its all fine with my implementation.

But theres a missbehavior, which i dont know how to solve right.

If the app is running and i plug my usb off and on again, a new second instance of my activity will be created with the first one still running. Just to make it clear: If i press the back button the second one disappears and the first instance shows his UI.

Im searching a way to restart my app if its already running and to start it if its not running. There is no need for saving data for any kind of reuse.

I tried some combinations with the flags FLAG_ACTIVITY_NEW_TASK, FLAG_ACTIVITY_BROUGHT_TO_FRONT and the FLAG_ACTIVITY_CLEAR_TOP. But i think these are the wrong ones for my case. Next try was to set the Activity in the manifast to singleInstance to be sure there can be no second instance. With no great success at all.

Can anyone give me an example to solve my problem like which flags i have to use?

  • 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-11T09:04:54+00:00Added an answer on June 11, 2026 at 9:04 am

    Set android:launchMode=”singleTask” in your activity tag in manifest file and try again…

    if your activity already running then not create new activity using above tag its show old running activity..

    you need to update UI or data in old running activity then use onResume method its called when intent broadcast…

    Thanks

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

Sidebar

Related Questions

First of all, let me say that I am not a professional coder -
Ahoy all! Long story short with this one if you don't mind lending a
First of all, this isn't for a keylogger, it's for an input in a
first of all some details: I configured security as below in web.xml view plaincopy
First of all, I'm quite new to the Android and JAVA world (coming from
first of all i would like to say i know its probably an easy
First of all there is probably a question like this already but i couldn't
First of all, apologize because I have seen some posts about this, but I
First of all I want to mention two things, One: My code isn't perfect
First of all I've gone through dozens of posting here on SO and google

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.