我正在阻止我的应用程序截图。为此,我使用
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
当用户想要截图时,我收到消息
"Couldn't save the screenshot, Stroage may be in use"
. 我想根据我的要求自定义此邮件。此外,当用户尝试截图时,我想点击web api。
我正在使用以下代码,但没有成功
public void detectScreenShotService(final Activity activity){
final Handler h = new Handler();
final int delay = 3000; //milliseconds
final ActivityManager am=(ActivityManager)activity.getSystemService(Context.ACTIVITY_SERVICE);
h.postDelayed(new Runnable(){
public void run(){
List<ActivityManager.RunningServiceInfo> rs=am.getRunningServices(200);
for(ActivityManager.RunningServiceInfo ar:rs){
if(ar.process.equals("com.android.systemui:screenshot")){
Log.e("tag", "Screenshot captured!!");
}
}
h.postDelayed(this, delay);
}
}, delay);
}