issue to select a PDF file from my mobile - java

i need to choose a pdf file on my mobile and upload the pdf file on a server, but i get this:" no application can perform this action"..why?
this is my code when i click on "select pdf file":
private void showFileChooser() {
Intent intent = new Intent();
intent.setType("application/pdf");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Pdf"), PICK_PDF_REQUEST);
}

You need to install some file explorers on your device first.

Related

trying open folder with intent

i want to open a specific folder from menu drawer in android app but when i run the app it open recent files folder.
this is my code
if (id == R.id.action_downloaded) {
if (PermissionUtilities.isPermissionGranted(mActivity, PermissionUtilities.SD_READ_WRITE_PERMISSIONS, PermissionUtilities.REQUEST_READ_WRITE_STORAGE_DOWNLOAD)) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory() + "/" + myfolder + "/");
intent.setDataAndType(uri, "application/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(Intent.createChooser(intent, "Select Pdf"), 1000);
}
Put as extra INITIAL_URI on your intent an uri the user choosed before with ACTION_GET_CONTENT.

Open a specific folder by clicking menu item

I try to click on a menu item with the help of this method to open a specific folder that the app creates in internal memory when .txt file is recorded, but this is not possible even though the folder exists. Can you help me when I click the menu item to open MyFolder, please.
switch (item.getItemId()) {
case R.id.openFolder:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
+ "/MyFolder/");
intent.setDataAndType(uri, "text/csv");
startActivity(Intent.createChooser(intent, "Open folder"));
break;
}
First of all, I would check if there is some file explorer on the system that would handle a request of opening directories this is an example.
Then your code should be modified to:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()+ "/MyFolder/");
intent.setDataAndType(uri, "*/*");
startActivity(Intent.createChooser(intent, "Open folder"));
also you may create the uri like this and I am not sure why this prefix is needed sometimes, maybe someone can explain to us:
Uri uri = Uri.parse("file://" + Environment.getExternalStorageDirectory().getPath()+ "/MyFolder/");

In an Android app, how to ignore the default app preferences and force users to choose apps?

When I send user to open a link in a browser, can I force the user to select from their available browsers, without using their default browser?
Try this:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
String title = "Select a browser";
Intent chooser = Intent.createChooser(intent, title);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(chooser);
}

Set orientation when picking a file from gallery

Currently I'm picking a file (Video) from the Gallery by doing:
private void selectVideo() {
Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Video"), REQUEST_TAKE_GALLERY_VIDEO);
}
The above will open the Gallery and let the user select a file, this works perfect.
My question:
Is there a way to set a fixed orientation of the Gallery when the user selects a file? I can't find any information about this, is this even possible?

Open multiple images in gallery intent

I need to open multiple images in gallery to view by sliding...
I know how to open 1 image..
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + "/sdcard/test.jpg"), "image/*");
startActivity(intent);
How can i view multiple images to view them all by sliding in a single intent.?
I have the path of the images... And i need to view them in gallery.
The EXTRA_ALLOW_MULTIPLE option is set on the intent through the Intent.putExtra() method to select multiple images
Multiple Image selection available only for above API 18
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
Full intent code is here:
Intent intent = new Intent(); intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"),1);
You can straight away show multiple images by accessing into your device's default gallery app.
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, SELECT_PHOTO);
There are 2 ways to implement multi-selection of images in gallery:
1.Intent for getting multiple images
2.Define custom gallery with fetching and loading photos from native gallery.
Intent for getting multiple images:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);
For implementation of gallery see this link: http://www.technotalkative.com/android-select-multiple-photos-from-gallery/
it fetches multiple images and shows them in a gridview
No you cant do that.... You need to create a new view activity

Categories

Resources