Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Check if service running in the background

// function that check if service is running in the background

 private boolean isMyServiceRunning(Context context) {
        ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
            if (BackgroundLocationUpdateService.class.getName().equals(service.service.getClassName())) {
                Log.e("isMyServiceRunning?", true + "");
                return true;
            }
        }
        Log.i("isMyServiceRunning?", false + "");
        return false;
    }
Comment

PREVIOUS NEXT
Code Example
Java :: Java Another form of assertion statement 
Java :: list to vector java 
Java :: java data structure interview questions 
Java :: current currency rates api 
Java :: java tic tac toe gui based using applet 
Java :: int to byte calculator 
Java :: find center of screen graphic g 
Java :: HQL . getFirstResult() 
Java :: java get if contains else 0 
Java :: action performed java swing code 
Java :: java replace second char of a string 
Java :: android paint drawtext multiline 
Java :: api to accept a csv file spring boot 
Java :: Maven test failure sure fire solved 
Java :: format code netbean 
Java :: Write program for problem 1 such that every regex runs as its own thread in java 
Java :: kotlin to java converter 
Java :: how to convert string to space separated int in java 
Java :: text blocks 
Java :: java thread syncronized locker 
Java :: OpenCV mat to float bytebuffer java 
Java :: create object in java without new keyword 
Java :: make for on all variable in class in java 
Java :: java using the segment Information already before the for-loop 
Java :: declare a variable java 
Java :: online currency rate api 
Java :: convert int to array in java 
Java :: RecyclerView scrolled UP/DOWN listener 
Java :: Lists - removing with iterator 
Java :: Goodbye to "Inspect Element" 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =