开发者

Android how to check if the intent service is still running or has stopped running

I need to know if all intentservices in the queu开发者_运维知识库e are "consumed" or the other way is to find out if it is still doing something so that I don't continue until all services have stopped running. Any ideas?


Try this may be useful for u

private boolean isMyServiceRunning() {
    ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if ("com.example.MyService".equals(service.service.getClassName())) {
            return true;
        }
    }
    return false;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜