大佬教程收集整理的这篇文章主要介绍了android – isApplicationBroughtToBackground安全功能经常行为不端,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
现在,问题是安全功能有时会显示两次.在挖掘了一下后,我注意到Activitymanager.getRunningTasks(1)中的topActivity有时仍然是您刚刚返回的活动.
就我而言,令人讨厌的挥之不去的应用程序是com.android.mms和com.google.android.apps.maps.
我在应用程序中也有一个呼叫设施,但它没有行为不端.
我对这种行为感到困惑.
为您的活动准备基础课程.在里面:
@Override protected void onPause() { Utils.wenTinBACkground(this); super.onPause(); } @Override protected void onResume() { Utils.wenTinForeground(this); super.onResume(); }@H_419_17@然后在静态实用程序类中有这样的:
public static void wenTinBACkground(final Activity which) { inBACkground = true; lastPaused = which.getClass().getSimplename(); final PoweRMANager poweRMANager = (PoweRMANager) which.getSystemservice(POWER_serviCE); final Boolean isScreenOn = poweRMANager.isScreenOn(); if (isApplicationSentToBACkground(which) || !isScreenOn) { // Do your security lockdown here. } } public static Boolean isApplicationSentToBACkground(final Context context) { Activitymanager am = (Activitymanager) context.getSystemservice(Context.ACTIVITY_serviCE); List<RunningTaskInfo> tasks = am.getRunningTasks(1); if (!tasks.isEmpty()) { ComponentName topActivity = tasks.get(0).topActivity; if (!topActivity.getPackagename().equals(context.getPackagename())) { return true; } } return false; } public static void wenTinForeground(final Activity which) { inBACkground = false; final String activityName = which.getClass().getSimplename(); if (lastPaused.equals(activityName) || !isLoggedIn()) { if (isLoggedIn()) { // Do your security lockdown here again,if necessary. } // Show your security screen or whatever you need to. } } public static Boolean isLoggedIn() { return loggedIn; }@H_419_17@
以上是大佬教程为你收集整理的android – isApplicationBroughtToBackground安全功能经常行为不端全部内容,希望文章能够帮你解决android – isApplicationBroughtToBackground安全功能经常行为不端所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。