Hello, I have a question on List.
Basically I have an application(API) I am testing.
When a start() method is called on the API, a bunch of things happen including starting a background service.
I have written / modified some code from the Web:
public boolean isServiceRunning(String serviceName){
boolean isRunning = false;
ActivityManager actvityManager = (ActivityManager)getContext().getSystemService( Context.ACTIVITY_SERVICE );
List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();
RunningAppProcessInfo proc = null;
for(int i = 0; i < procInfos.size(); i++){
proc = (RunningAppProcessInfo)procInfos.get(i);
if(proc.processName.equalsIgnoreCase(serviceName)){
isRunning = true;
}
}
return isRunning;
}
When I pass in the process name prior to calling start, the method returns false as expected.
When I call start() the method returns true as expected.
However when I call stop() after start() I expect the service to stop. Looking at the running services section in the android applications section I can see the service has in fact stopped but the call to my method is still returning true.
Any thoughts... I suspect it is context related but really at a loss
Thanks in advance
Sean