处理检测app进去后台的时候提示用户 也就是在onPause的时候

    /**     * Is foreground boolean.     *     * @param context the context     * @return the boolean     *//*判断应用是否在前台*/    public static boolean isForeground(Context context) {        try {            ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);            assert am != null;            List tasks = am.getRunningTasks(1);            if (!tasks.isEmpty()) {                ComponentName topActivity = tasks.get(0).topActivity;                if (topActivity.getPackageName().equals(context.getPackageName())) {                    return true;                }            }            return false;        } catch (SecurityException e) {            e.printStackTrace();            return false;        }    }
if (!Selfutils.isForeground(this)) {            setShow(Config.uiStyle + "应用仍在后台运行,如需退出,请先进入"+Config.uiStyle+"应用,按手机“返回键”退出。");        }

更多相关文章

  1. Android(安卓)Studio Check Updates Connection failed (Connect
  2. Android之提示java.lang.RuntimeException: Parcel: unable to m
  3. android eclipse debug 调试 Source not found
  4. android环境搭建 ADT(jdk+eclipse+android sdk)
  5. android java js 回调 真心好用
  6. Android(安卓)APP更新_后台下载、自动安装
  7. Android(安卓)代码提示无效
  8. android中XMl文件的读取
  9. android 巨坑 Received close_notify during handshake 或 Conne

随机推荐

  1. C#引用类型: 按值传递,按引用传递的对比
  2. C++中的四种强制类型转换_基本用法及使用
  3. 探索C++虚函数在g++中的实现(动多态)_虚函
  4. C++11新特性 - 多态和虚函数,override说明
  5. 最新使用C#生成二维码方案,详解及实例 ( Q
  6. 简要分析Unity计时器脚本Timer的用法(附代
  7. C++11新特性- 纯虚函数和final说明符的用
  8. 仪器设备改造技术,实现测量数据上传到服务
  9. 技术解答CSV 文件的一个 .NET 库:CsvHelpe
  10. C++11常用语法- explicit类型转换运算符