Is there anyway to open Gallery faster through android studio? like the way facebook messenger does or whatsapp does? I making my own app and every time i tap the button to open gallery, it takes a few seconds. (I know it't not because of the phone because other apps open gallery really fast). Actually it's not that slow either but i'd really like it if it opened with a blink of an eye. Although I do have have a lot of computation on the images like resizing and changing orientations in onActivityResult(), but that shouldn't matter should it? btw here is my code for opening the gallery:
public void openGallery(View view)
{
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);//
startActivityForResult(Intent.createChooser(intent, "Select Picture"),IMAGE_GALLERY_REQUEST);
}
Can anyone help me with this?
Are you using Emulator? If so try Device.
I am using this:
Intent i = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, IMAGE_GALLERY_REQUEST);
It takes only a second or less to open Gallery.
Related
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.
I am using this code
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
photoPickerIntent.setType("image/*");
photoPickerIntent.setAction(Intent.ACTION_GET_CONTENT);
photoPickerIntent.addCategory(Intent.CATEGORY_OPENABLE);
photoPickerIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
startActivityForResult(Intent.createChooser(photoPickerIntent, "Image File Picker"), 1000);
to pick image from sdcard within my application.
this is working fine, according to my requirement i need to close that ACTION_PICK chooserActivity myself, like when we touch outside the dialog that will closed fine...
but how can we close this type of dialog programmatically?
You can't.
That chooser is actually a separate activity, launched by intent (which will then launch another activity via intent when the user selects something).
You don't control that chooser, its not actually in your app.
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);
I am working on an app that accesses the camera and returns an uri, which I pass to another activity and display the extracted bitmap in an ImageView. Everything seems to work fine. Here is the code that I use to initiate the camera intent.
mCameraButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mCameraUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues());
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCameraUri);
mtimeCameraAcessed = System.currentTimeMillis();
startActivityForResult(cameraIntent, RECEIVE_CAMERA_PICTURE);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
}
});
But, I have noticed a discrepancy. When my application access the camera, the gallery icon at the bottom of the screen seems to be missing (the icon appears when you access the camera application on any android phone). I have attached a couple of screenshots to illustrate this.
I want the user to access the camera while being able to change his/her mind and then access the gallery on the same screen (by tapping the gallery icon). Now, I do know how to initiate a gallery intent via 'Intent.ACTION_PICK'. I have also looked at the this question, but I don't completely agree that I need a custom camera layout to achieve what I intend to do: Single intent to let user take picture OR pick image from gallery in Android
The reason I say this is because, I have seen apps such as QuickPic that access the camera application with the gallery icon at the bottom. Can anyone please throw some light on this?
After going through some thorough research, I have come to a conclusion that this is infact impossible. However, a custom layout combined with the camera api would be the ideal solution if something like this is desired. But then, I have observed that using the camera api has certain problems such as skewed appearance of the camera screen.
QuickPic takes the user to the camera screen (with the gallery icon) but drops him/her out of the app while doing so. At that point, the user is basically using the stock camera app on Android and not the Quickpic app itself.
When using the following code to select a picture from my gallery, I also have the option to take a new picture, when I do it saves it (in the default image gallery) and I can select that image.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(
Intent.createChooser(intent, "Select Picture"),
PICK_IMAGE);
My ultimate goal is to have two options "select from gallery" and "take picture". My question - is there a way to boot the camera automatically via the above Intent, possibly with some extras?
And I don't mean using the camera intent:
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
While testing with the camera intent I have been running into two main bugs: Ok button bug and the small image return, so I was wondering if my other method is possible. Probably not, but its worth a shot..?
As far as I know, the answer is no. The best method is getting the Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); to play nicely. Even if it were possible, the user interaction would be unintuitive and confusing as there would be no "accept photo" button/interaction.