Disable screen shot in my android app

2019-03-20 14:36发布

问题:

I have my current android application which do not allow user to take screen shot.

I am using getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE); in my onCreate() method and working perfectly fine.

Now my problem is in one of my screen I am navigating user to Google map with some routes. I don't want user to take screen shot in that screen too. My current implementation disables user to take screen shot from my app. But I don't want that user can take screen shot of Google Map too when he goes from my app. Is there any solution for this or any work around. Any help will b highly appreciated.

回答1:

Instead of prompting the 3rd party app, consider using a MapActivity.

Then you can you can place a MapView in the layout and show the Map. In this case, you will be able to control the restriction via the secure flag.

Just place the same code in the onCreate() method like you did on the other activity.