Image Upload in Android - android

I'm trying to upload an image to my application. I'm using the following lines to achieve this.
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),
PICK_IMAGE);
But when opening gallery it shows me many folders such as "Recent Images", "Documents", "Google Drive" etc.,
Here instead showing like this I would like to show only the gallery folder. Can you please help me how I can achieve this?

Try this
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),
PICK_IMAGE);

Related

how to select pdf file using intent and get that selected pdf file path in onActivityResult

I am trying to select pdf using intent and get that selected pdf file path I am not sure its right or wrong.
if not then how can I get pdf path in onActivityResult.
.
Intent intent = new Intent();
intent.setType("pdf/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select PDF"), PDF_PICKER_RESULTS);
using application/pdf line i can do this things.
Intent intent = new Intent();
intent.setType("application/pdf");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select PDF"), PDF_PICKER_RESULTS);

Intent.ACTION_GET_CONTENT open images and pdf

i am trying to open recent window which will have only image and pdf selectable
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
but in this i can select only image how i can add pdf also
you can do the following using EXTRA_MIME_TYPES (from API 19):
final String[] ACCEPT_MIME_TYPES = {
"application/pdf",
"image/*"
};
Intent intent = new Intent();
intent.setType("*/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra(Intent.EXTRA_MIME_TYPES, ACCEPT_MIME_TYPES);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
UPDATE
There is also another solution but it may or may not work based on users experiences but you can try it to see if it works in your case:
intent.setType("image/*,application/pdf");
However the application that you try to invoke should also supports to MIME types as well

Open file manager error android

Hi there all developers:
I am using this code snippet
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE);`
There exists a file manager, but its giving a messege<< No apps can perform this action. Why?? Can anyone tell me?
I have also tried without Intent.ACTION_PICK
Please put my code.
it is working.
* CODE *
Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivity(intent);

Store audio in the directory of applications and way to get to use?

I do not speak English! Please people ignore.
I want save audio from
Intent intent = new Intent();
intent.setType("audio/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(
Intent.createChooser(intent, "Select Picture"),
SELECT_PICTURE);
to other directories.
Try this
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
startActivityForResult(tmpIntent, 0);

Android image picker for local files only

I'm using the built in Android image picker as follows:
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
m_activity.startActivityForResult(photoPickerIntent, PHOTO_PICKER_ID);
Is there any way to restrict this to show only locally available files. On my device it is currently picking up Picasa thumbnails and I'd like to exclude all images that are not actually present on the device.
Adding intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); will allow for local files only. It will exclude picasa images. Hope this helps.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
startActivityForResult(Intent.createChooser(intent,
"Complete action using"), PHOTO_PICKER_ID);
User this code to launch intent to get local image chooser.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Complete action using"), PHOTO_PICKER_ID);

Categories

Resources