In this tutorial we are going to show how to protect your application from screen shot capturing. Some applications might be having sensitive personal data (for example all banking applications), so as a developer we need to disable the option to take screen shot using DDMS console.
See following steps :
Use WindowManager.LayoutParams.FLAG_SECURE before setContentView() mehtod
Note: There is no application level protection. You have to add this code in all the activities that you want to protect.
Generally, when you take a screenshot, you will see a “Screen Capture” notification in the notification bar and you can see that screenshot in the Gallery app if you click that notification. Now, if you use FLAG_SECURE, the Notification will be “Can’t take screenshot…….” as below,
Do as follow,
In your Activity.Java
________________________________________________________________________________
See following steps :
Use WindowManager.LayoutParams.FLAG_SECURE before setContentView() mehtod
Note: There is no application level protection. You have to add this code in all the activities that you want to protect.
Generally, when you take a screenshot, you will see a “Screen Capture” notification in the notification bar and you can see that screenshot in the Gallery app if you click that notification. Now, if you use FLAG_SECURE, the Notification will be “Can’t take screenshot…….” as below,
Do as follow,
In your Activity.Java
import android.view.WindowManager;
public class MainActivity extends AppCompatActivity {
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE);
setContentView(R.layout.main_activity);
}
}
However, not everything in
the activity will be protected. Any pop-up windows —
Dialog
, Spinner
, AutoCompleteTextView
, action bar
overflow, etc. — will be insecure. You can fix the Dialog
problem by
calling getWindow()
on it and setting FLAG_SECURE
. The rest... gets
tricky. ________________________________________________________________________________
Comments
Post a Comment