以下两种方式任选其一:
1、使用第三方的专业防界面劫持 SDK,防止应用界面被劫持。
2、开发者自查:
@Override
protected void onPause() {
super.onPause();
String topActivityPackage = null;
ActivityManager activityManager = (ActivityManager)
(MyApplication.myContext.getSystemService(android.content.Context
解决方案
.ACTIVITY_SERVICE));
List<ActivityManager.RunningTaskInfo> runningTaskInfos =
activityManager
.getRunningTasks(1);
if (runningTaskInfos != null) {
ComponentName f = runningTaskInfos.get(0).topActivity;
topActivityPackage = f.getPackageName();
if(topActivityPackage.equalsIgnoreCase("自身应用包名"))
{ AlertDialog.Builder builder = new
AlertDialog.Builder(MainActivity.this); builder.setTitle("警告");
builder.setPositiveButton("检测到窗口被劫持" , null ); builder.show(); }
}
refresh();
}
3***@qq.com
- 发布:2023-11-02 13:52
- 更新:2023-11-02 13:52
- 阅读:269
0 个回复