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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:23:13+00:00 2026-06-18T19:23:13+00:00

My android app used to got killed in background even with foreground service. Here

  • 0

My android app used to got killed in background even with foreground service.
Here is the manifest entry for the service :

 <service
            android:name=".MyService"
            android:icon="@drawable/icon"
            android:label="TritonHK"
            android:process=":my_process" >
        </service>

and here is the code for service

 MLog.w(getClass().getName(), "TritonHK started");

         Notification note=new Notification(R.drawable.icon,
                                             "TritonHK is running",
                                             System.currentTimeMillis());
         Intent i=new Intent(this, BGMessages.class);

         i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|
                    Intent.FLAG_ACTIVITY_SINGLE_TOP);

         PendingIntent pi=PendingIntent.getActivity(this, 0,
                                                     i, 0);

         note.setLatestEventInfo(this, "TritonHK",
                                 "TritonHK",
                                 pi);
         note.flags|=Notification.FLAG_NO_CLEAR;

         startForeground(1337, note);

and here is how I am starting my service:

Intent i=new Intent(this, MyService.class);

        startService(i);

I am starting the service in onCreate of my first activity.

I have over come this bug by removing android:process=":my_process" from my service in manifest, now it looks like this:

 <service
                android:name=".MyService"
                android:icon="@drawable/icon"
                android:label="TritonHK"
                 >
            </service>

But now I am facing an interesting problem.

When I install the app on my device and after installation successful I click on done and launch my app from the icon, It runs fine.

But after installation successful If I launch the app by clicking open button It got killed in background for very first time. Then If I force close the app and launch it from icon again then it runs fine.

I am puzzled what is going wrong. Please help me

  • 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-18T19:23:14+00:00Added an answer on June 18, 2026 at 7:23 pm

    I have resolved the problem with the following code and posting the same so that others can also use this.

    I have added below code to the on create of my launcher activity.

    if (!isTaskRoot()) {
                final Intent intent = getIntent();
                final String intentAction = intent.getAction();
                if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) &&
                        intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) {
                    finish();
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my android app I have used InMobi ad sdk to show banner ad's.
I want to create an Android app that can be used on 2.3.3 all
I made a twitter integration to my android app. I used this great tutorial,
I have used an app to stream Android Audio with RTMP, the app is
I've created an app on Android 2.2 and used emulator to to test the
I am developing a simple sip-based voip app for android. I used this sample
I have got a runtime exception while developing an App. Here is my LogCat.
We've got an android app and an iPhone app (same functionality) that use sqlite
So I've got my first Android app well-developed and moving along. I've got a
I had build in past an android app that i used Jsoup to parse

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.