Use below code in onCreate()
of your Activity
:
getWindow().setFlags(LayoutParams.FLAG_SECURE,
LayoutParams.FLAG_SECURE);
setContentView(R.layout.main);
above code work for particular activity also.If you
do not work this code then other problem there may be import of layout param wrong or place of code wrong.
Be careful about using WindowManager.LayoutParams.FLAG_SECURE
, on some devices, this will make the view scrambled. Looks like a Samsung specific bug. I recommend the following:
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
}