【问题标题】:Android how to check if the intent service is still running or has stopped runningAndroid如何检查意图服务是否仍在运行或已停止运行
【发布时间】:2011-09-16 05:27:09
【问题描述】:

我需要知道队列中的所有意图服务是否都已“使用”,或者另一种方法是确定它是否仍在执行某些操作,以便在所有服务停止运行之前我不会继续。有什么想法吗?

【问题讨论】:

    标签: android intentservice


    【解决方案1】:

    试试这个可能对你有用

    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;
    }
    

    【讨论】:

    猜你喜欢
    • 2021-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-09
    • 1970-01-01
    • 2017-02-23
    相关资源
    最近更新 更多