Disable screenshot - android

I am using below code to view image with the help of default gallery,
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(photoURI, "image/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
But at the same time i want to disable screenshot when users view image using gallery. I can disable screenshot directly for my app screen but can't do when image is viewed from gallery.
Please help me.

You can't. If you need that functionality, don't use gallery and write your own display code. Although that's 99% useless- if a user really wants to screenshot his own phone, he can. Worst case he can grab a second phone and take a picture.

Related

Start Android gallery app without specifying or picking image

How can we start the gallery app in Android without telling it which file to display?
This is because I want to show images in an album/folder. However, I understand there is no such function. So, I would like to just start the gallery app.
ACTION_VIEW will always result in an "unsupported file" message, if there is no URI specified, or if MediaStore.Images.Media.EXTERNAL_CONTENT_URI is specified. This is bearable, but not desirable, as it tells the user something is wrong with my app.
ACTION_PICK works partially, but the later half is not what I want. I want the user to choose images, and see the chosen images in the gallery. The gallery should not return the URI to my app, and expect my app to display it. There is a reason for this, that is, I want the user to be able to switch from one image to another without returning to my app. The user should return only after he/she has decided not to view anymore image.
The code that I have tried :
intent = new Intent (Intent.ACTION_VIEW);
intent.setType ("image/*");
startActivity (intent);
intent = new Intent (Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivity (intent);
Any suggestion?

Android photoviwer VIEW intent only showing 1 image

In my android app, I create an intent to display an image in the photogallery app.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file:///storage/sdcard0/arin/category/1/1.png"), "image/*");
context.startActivity(intent);
This opens the photo app and shows that image but only that image...
I know there are other images in the same folder. But the app wont let swipe left/right and switch images. How can I change the code so it will let me see the other pics in the same folder...
Thanks
How can I change the code so it will let me see the other pics in the same folder
Write your own "photogallery" code.
There are hundreds, perhaps thousands, of apps that are capable of responding to your Intent. None of them have to offer any means to "swipe left/right and switch images". If you want a specific set of behaviors, write them yourself. If you want the user to be able to view the image in the user's chosen app, then stick with your existing code and do not worry about the behavior of the user's chosen app.

Open camera app with a thunbnail icon

I want to launch Android built-in camera app with a thumbnail icon on the right-bottom. Here is my code to open the camera app.
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
I think I need to put a intent data to do it. I look forward to your help.
Thanks.
Just create an image button, or button or anything you desire really.
In the onclick event add something like:
String saveFileName= Environment.getExternalStorageDirectory() + "/test.png";
// BUILT IN CAMERA
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
camera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(saveFileName) );
this.startActivityForResult(camera, 1);
Make sure you have necessary permissions set. Like saving to the SDCard.
You are very close, you dont need those flags set. And you should ideally specify where you are saving the image.
If you are wondering how to make the button take a look here

Intent.ACTION_VIEW does not allow edit in gallery app

I have an app which wants to view an image in the gallery app.
I use this code to view it:
File cachedImage = cache.getFile(image.getImageUrl());
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(cachedImage), "image/*");
startActivity(intent);
This works except when I click the edit setting here:
and I get the no apps can perform this action message:
Is there some way to make this work? Do I need to pass additional extras? I know the Gmail app is able to view an image attachment in the gallery and the edit function works. This is on JellyBean.
Is there some way to make this work?
Install an app that can edit pictures. Your screenshots appear to be of the Gallery app, which is presumably trying to use ACTION_EDIT to start an activity to edit the picture, and there is no such activity available.

Calling gallery to bring back an image

I'm writing a code for my app, and i got stuck which trying to figure this out.
I want to call GALLERY from by app and then if the user selects an image, that image is brought back to my app for further actions instead of Gallery opening it.
Plz help me coding this, thanks in advance :)
Check here for an answer: Pick an image from the Gallery
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
//intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, 1);

Categories

Resources