how run Background Service after i destroy my application?

how run Background Service after i destroy my application?

By : user2948711
Date : November 15 2020, 06:54 AM
this one helps. You can act in the following manner:
create the Service you need, describe it in AndroidManifest and configure intent-filter create BroadcastReceiver and in AndroidManifest configure it's intent-filter to receive BOOT_COMPLETED event in the receiver you should set a repeating alarm (see docs https://developer.android.com/training/scheduling/alarms.html), and configure alarm's PendingIntent to fire up the Service
code :

Share : facebook icon twitter icon
i want to start service when application comes to background and stop service when application is in foreground

i want to start service when application comes to background and stop service when application is in foreground

By : GopiK
Date : March 29 2020, 07:55 AM
it fixes the issue
I used onPause() and onResume(), but i have to handle it in every activity.
code :
public class MyBaseActivity extends Activity {

    // Put any methods you need here that are common to all of your Activities

public class ActivityOne extends MyBaseActivity {


Stop the Service on Destroy of Application

Stop the Service on Destroy of Application

By : konmin
Date : March 29 2020, 07:55 AM
hope this fix your issue I am confused right now , about service concept of running and stopping: , First of all, launch the "LocationService" on your app start:
code :
public class MyApp extends Application {

    private static final String TAG = "MyApp";

    public void onCreate() {
        Log.d(TAG, "App started up");
        startService(new Intent(this, MyLocationService.class));
    public int onStartCommand(Intent intent, int flags, int startId) {
        return START_NOT_STICKY;
On Application Destroy, Android is re-creates the service

On Application Destroy, Android is re-creates the service

By : tomoe tomoya
Date : March 29 2020, 07:55 AM
wish helps you This has been asked so many times, I have seen and applied many answers but nothing seems to be helping here. , You have to use IntentService instead of Service why?
how to stop updating progress bar that showing on notification panel from background Service when on Destroy() of Servic

how to stop updating progress bar that showing on notification panel from background Service when on Destroy() of Servic

By : serhan inci
Date : March 29 2020, 07:55 AM
Hope this helps Thread.interrupt() does not interrupt the thread immediately. It only update interrupt status of thread. If your thread contains method which poll the interrupt status (i.e. sleep ) only then the thread will be interrupted otherwise the thread simply complete the execution and interrupt status will be ignored.
So, In your case you do following way:
code :
private class MyWorkerThread extends Thread {

    public MyWorkerThread(String name) {

    private boolean isStopThread = false;

    public void setStopThread(boolean isStopThread) {
        this.isStopThread = isStopThread;

    public void run() {

        for (int i = 0; i <= 100; i += 5) {
            // Sets the progress indicator completion percentage

            try {

                if (mWorkerThread.isStopThread) {
                    Log.d("Thread", "thread is interrupted , so breaking loop !");
                    mWorkerThread = null;

                mBuilder.setProgress(100, i, false);
                mNotifyManager.notify(0, mBuilder.build());

                // Sleep for 5 seconds
                Thread.sleep(2 * 1000);

            } catch (InterruptedException e) {
                Log.d("TAG", "sleep failure");


        mBuilder.setContentText("Download complete");
        // Removes the progress bar
        mBuilder.setProgress(0, 0, false);
        mNotifyManager.notify(0, mBuilder.build());

private void updateService() {

        mWorkerThread = new MyWorkerThread("MyWorkerThread");

    public void onDestroy() {

        Toast.makeText(getApplicationContext(), "service Destroyed", Toast.LENGTH_SHORT).show();

        //  mNotifyManager.cancelAll();
        //Setting flag for stop thread

        // mNotifyManager.cancel(0);

        // mNotifyManager.notify(0, mBuilder.build());

How to make a service remain alive if the application is destroy from the memory

How to make a service remain alive if the application is destroy from the memory

By : mustbejhe
Date : March 29 2020, 07:55 AM
I wish this helpful for you Removing app from recent apps list kills app process. Returning START_STICKY from onStartCommand() means you want the system to restart the service after it was killed (either because you removed the app from recents list or system killed service because it ran out of resources).
If you want to keep your service (and it's process) alive you will need foreground service. System tries to keep foreground services alive as long as possible. See: Running service in foreground
Related Posts Related Posts :
  • FastAdapter: Undo button does not show up after swipe
  • What are reasons to pass getActivity as the LifecycleOwner to the LiveData's observe method in a fragment?
  • Implement Face Recognition in Android
  • Titanium studio cannot run "titanium" command in terminal
  • How to execute command line ffmpeg commands programatically in android?
  • Make Android List Items clickable with each item pointing to a different link
  • listview runs successfully, but nothing is display in emulator
  • How to zoom in a bitmap with high resolution?
  • Passing listView data through intent
  • Google map route direction show by arrows in android v2
  • how to start "uiautomator test run" from android code?
  • Proguard in Android Library
  • Alarm Clock from GIT - Gives error - Android
  • Mock injection using Mockito - Android
  • Get Bitmap from universal image loader
  • Unable to include custom font in android
  • Basics on using logcat in Android development
  • Android: Clear cache programmatically
  • Android: pass object without serialization
  • Can not scroll and click item on gridview inside scrollview
  • Android device keeps disconnecting from adb / eclipse
  • Volley cannot create cache directory. Could not clean up file
  • ShareActionProvider icon in actionbar
  • How to open a custom attachment using an Android app?
  • Unable to add column dynamically into the sqlite table
  • android persistence activity which never stop
  • The Google Play services resources were not found. Check your project configuration to ensure that the resources are inc
  • How to select files from google drive in android?
  • Run a AsyncTask every 10 seconds until cancelled
  • Blur on touch. Android application
  • NDK Android - Can't build ARMv5 and V7 at the same time
  • Android development with Eclipse clean and build
  • How to set Different Key Background for every Key in Android Custom Keyboard
  • Face recognition using OpenCV in android?
  • Tumblr API - Jumblr for Android [OAuthConnectionException]
  • Small Icon on Notification not working correctly
  • ConstraintLayout match parent height on larger screens but scroll on smaller
  • Kotlin version issue
  • How can i make my android app look the same on RTL and LTR languages?
  • Can not detect Android NDK toolchain
  • Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only.
  • Facebook Key Hash for Play Store Release
  • backbutton confirm exit app android + phonegap + jquery
  • How to Make Instagram Listview in android?
  • Up and Down Enemy Movement using translate corona sdk
  • Set selection method is not working in gallery in android
  • How to implement onOptionsItemSelected for Sub-Menu Items?
  • HttpHostConnectException connection refused ConnectException ErrnoException
  • Adding Buttons to expendableListView as last Child
  • Android. Block phone on startup
  • How to programmatically check If string is not to wide to fit onto the screen in Android
  • EditText box cursor appear after touching box?
  • using if statement when video is done playing
  • Add to Aspectpath not found MonkeyTalk
  • GooglePlusUtil cannot be resolved (Android)
  • Trouble understanding Relative Layout
  • How to title/name each fragment separately to appear on PagerTitleStrip?
  • Android webView blinks
  • Available service types in WifiP2pDnsSdServiceInfo.newInstance
  • Hide only bottom action bar Android
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org