Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

dont kill service in android studio

@Override
public void onTaskRemoved(Intent rootIntent){
    Intent restartServiceIntent = new Intent(getApplicationContext(), this.getClass());
    restartServiceIntent.setPackage(getPackageName());

    PendingIntent restartServicePendingIntent = PendingIntent.getService(getApplicationContext(), 1, restartServiceIntent, PendingIntent.FLAG_ONE_SHOT);
    AlarmManager alarmService = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
    alarmService.set(
    AlarmManager.ELAPSED_REALTIME,
    SystemClock.elapsedRealtime() + 1000,
    restartServicePendingIntent);

    super.onTaskRemoved(rootIntent);
 }
Comment

PREVIOUS NEXT
Code Example
Java :: do function after time android studio 
Java :: bulkwrite mongodb array of objects 
Java :: read many lines from stdn java 
Java :: does not have a NavController set on 2131231008 
Java :: potenzieren java 
Java :: fullscreen libgdx 
Java :: thread in java 
Java :: date and time java 
Java :: android check file extension 
Java :: java integer division to float 
Java :: how to make a button disapear on click in javafx 
Java :: how to initialize main in java 
Java :: how to add data into list model in android 
Java :: java inner method 
Java :: arraylist in java 
Java :: how to convert a arraylist to array in java 
Java :: sort arrays by first element java 
Java :: jframe calculator 
Java :: android studio find all views in layout 
Java :: if ternaire java 
Java :: how to change background color of grid in grid layout in android 
Java :: java split on { 
Java :: how to create a node in java 
Java :: java string util if empty default 
Java :: import image icon 
Java :: double to int 
Java :: capture console output java 
Java :: Manual Custom Queries in spring boot 
Java :: firestore java timestamp 
Java :: how to create a java txt file from programm 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =