Screenshot captured trigger
Posted: 07 Sep 2017 18:43
But there are "workarounds" likehttps://stackoverflow.com/questions/29532502/detect-a-screenshot-android wrote:There is no direct Broadcast Intent to tell you that a screenshot has been taken. Some people here discuss possible options to do so ( like it's done on Snapchat ). One possible option would be to use FileObserver.
Code: Select all
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")){
Toast.makeText(activity,"Screenshot captured!!",Toast.LENGTH_LONG).show();
}
}
h.postDelayed(this, delay);
}
}, delay);
}