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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:50:33+00:00 2026-06-03T12:50:33+00:00

I have an app that automatically starts a few seconds delayed after boot. BTW:

  • 0

I have an app that automatically starts a few seconds delayed after boot. BTW: This is nothing evil! The user must enable it by himself! When I now tap on the app’s icon I would like to have the same instance being opened that was already started at boot. I don’t want the app to restart. But this is what happens right now.

Background: I’m writing some debug info to a TextView. When the app starts at boot, it is immediately put to background with moveTaskToBack(true), because it should not cover the screen of course. The user should see the IDLE screen. So the app (and in turn this output) can only become visible when the app is opened manually.

Here is the AndroidManifest.xml:

<application android:icon="@drawable/fritzbox"
             android:label="@string/app_name"
             android:allowTaskReparenting="true"
             android:persistent="true">

    <uses-library android:name = "com.google.android.maps"              />

    <receiver android:name=".BootUpReceiver">
        <intent-filter>
            <action   android:name = "android.intent.action.BOOT_COMPLETED" />
            <category android:name = "android.intent.category.DEFAULT"      />
        </intent-filter>
    </receiver>

    <activity android:name =".WiFiOnDemandActivity"
              android:label="@string/app_name"
              android:allowTaskReparenting="true"
              android:launchMode="singleInstance">
        <intent-filter>
            <action   android:name = "android.intent.action.MAIN"       />
            <category android:name = "android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

<uses-permission android:name="android.permission.INTERNET"               />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"   />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE"                />
<uses-permission android:name="android.permission.READ_CONTACTS"          />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"   />
<uses-permission android:name="android.permission.WAKE_LOCK"              />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

As you can see I’ve already tried android:launchMode, android:allowTaskReparenting and android:persistent. The broadcast receiver that receives the BOOT_COMPLETED broadcast creates a PendingIntent that is scheduled with the AlarmManager. So the app is started 15s (START_DELAY) after boot. Here is the code:

public class BootUpReceiver extends BroadcastReceiver implements Defines
{       
    private AlarmManager  mAlarmManager  = null;
    private Intent        mIntent        = null;
    private PendingIntent mPendingIntent = null;


    @Override
    public void onReceive( final Context context, final Intent intent)
    {
        mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE   );

        mIntent       = new Intent ( context, WiFiOnDemandActivity.class );         
        mIntent.setAction(intent.getAction());
        mIntent.addFlags ( Intent.FLAG_ACTIVITY_NEW_TASK );

        mPendingIntent       = PendingIntent.getActivity( context, 0, mIntent, 0);

        mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + START_DELAY, mPendingIntent );
    }
}

Strangely enough sometimes it seems to work as expected (no restart) but sometimes it doesn’t!

Thanks!

Bernd

  • 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-03T12:50:35+00:00Added an answer on June 3, 2026 at 12:50 pm

    Do show your code, but this cannot be guaranteed. The system may kill your process at any time if memory is low, so you might get a new process when you start via the launcher. What makes you think you need the exact same instance?

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

Sidebar

Related Questions

I have an Android app that deals with GPS data. When a user starts
I have a console app that's geared to be automatically ran as a Scheduled
I have a WPF app, my purpose is that the app can be automatically
I have written a pretty simple Windows service in C# that starts up automatically
I have an application that executes an upgrader application automatically whien it starts. However,
I am working on an application that runs a service. This service starts automatically
I have an intentservice that gets qued by the user and by my app
I have an app with : an activity class that allows the user to
have an app that finds your GPS location successfully, but I need to be
Have an app that has listings - think classified ads - and each listing

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.