0

This is boolean that check service is running or not.
I can't use this in onCreate.

CODE:

private boolean isMyServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (ser.class.getName().equals(service.service.getClassName())) { return true; } } return false; } 

How to check boolean in onCreate?

2
  • 1
    what is the question? Commented Jan 18, 2014 at 20:30
  • I want to use boolean in onCreate. Commented Jan 18, 2014 at 20:32

1 Answer 1

1

You should be able to call in in the same class. If you want to call it outside the class simple make it public instead of private.

Usage example:

if(isMyServiceIsRunning){ //Do something } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.