Android安全检查之Activity劫持检测
16lz
2021-01-24
处理检测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+"应用,按手机“返回键”退出。"); }
更多相关文章
- Android(安卓)Studio Check Updates Connection failed (Connect
- Android之提示java.lang.RuntimeException: Parcel: unable to m
- android eclipse debug 调试 Source not found
- android环境搭建 ADT(jdk+eclipse+android sdk)
- android java js 回调 真心好用
- Android(安卓)APP更新_后台下载、自动安装
- Android(安卓)代码提示无效
- android中XMl文件的读取
- android 巨坑 Received close_notify during handshake 或 Conne