TrueBlueDrive / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

Service checking #334

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello , 

It would be great if there was a method for checking that a certain service for 
an app is running or not. 

Right now I have the following method which return a boolean if a service is 
running or not. 

The only thing worth mentioning is that the string passed must be the same as 
declared in the apps. manifest.

    private boolean isServicerunning(String serviceName) {
        ActivityManager manager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
        for (RunningServiceInfo service : manager
                .getRunningServices(Integer.MAX_VALUE)) {
//          Log.i("Debug", "All services running : " + service.service.getClassName());
            if (serviceName.equals(service.service.getClassName())) {
                return true;
            }
        }
        return false;

    }

Original issue reported on code.google.com by zeus.tl on 1 Oct 2012 at 8:49

GoogleCodeExporter commented 9 years ago
Dunno' why it was submitted as a defect :-? 

Original comment by zeus.tl on 1 Oct 2012 at 8:50

GoogleCodeExporter commented 9 years ago
Thanks for this. It will be included in the next release.

Original comment by renasr...@gmail.com on 2 Oct 2012 at 4:35

GoogleCodeExporter commented 9 years ago
We have decided to not add this functionality as users have not found an 
interest in it. 

Original comment by renasr...@gmail.com on 3 Apr 2013 at 3:59