美文网首页
andorid app home 返回桌面之后app 重新打开,

andorid app home 返回桌面之后app 重新打开,

作者: 陈陈_04d0 | 来源:发表于2020-10-14 16:03 被阅读0次

    if (!isTaskRoot()) {

    // 判断当前activity是不是所在任务栈的根

        Intent intent = getIntent();

        if (intent !=null) {

    //判断使用页面是否已经存在。

    if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(intent.getAction())) {

    finish();

    return;

            }

    }

    }

    /** 课外知识

    * 判断服务是否在运行

    *

    * @param context

    * @param serviceName

    * @return 服务名称为全路径 例如com.ghost.WidgetUpdateService

    */

    public boolean isRunService(Context context, String serviceName) {

    ActivityManager manager = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);

        for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {

    if (serviceName.equals(service.service.getClassName())) {

    return true;

            }

    }

    return false;

    }

    相关文章

      网友评论

          本文标题:andorid app home 返回桌面之后app 重新打开,

          本文链接:https://www.haomeiwen.com/subject/hagmpktx.html