I'm trying to use Intent ACTION_GET_CONTENT to open an application such as (File Manager, File explorer etc...). However once I am in the File Manager, I am only able to open the file. The Copy to.. and Move to... capabilities are not shown when opening File Manager app using this method. Is ACTION_GET_CONTENT only used for opening files?
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath());
intent.setDataAndType(uri, "*/*");
startActivity(Intent.createChooser(intent, "Open folder"));
Here is the image showing the open option only:
Related
Here is the intent I use to open a word file:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_EDIT);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(fileUri, MimeTypeMap.getSingleton().getFileExtensionFromUrl(fileUri));
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
mContext.startActivity(intent);
I feth the fileUri using this line:
FileProvider.getUriForFile(context, "my authority", file);
File is opened correctly in both Microsoft word app and OfficeSuite app, but in both apps, the file is in read only mode and I cannot edit the file directly. When I open that word file with a file manager app like ES File Explorer, the file is in read write mode and edit is enabled.
I tried both ACTION_VIEW and ACTION_EDIT and the same happened.
I want to show downloaded file in File Manager by giving the File absolute Path.I read a lot about it and find same thing
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(file.getAbsolutePath());
intent.setDataAndType(uri, "*/*");
startActivity(Intent.createChooser(intent, "Open folder"));
And it results to view only recent files that has been viwed. Please guide to Open File Manager while navigating it to file whose absolute path has been given.
I read a lot about it and find same thing
ACTION_GET_CONTENT has little to do with a file manager.
Please guide to Open File Manager while navigating it to file whose absolute path has been given.
There is nothing on Android for this, sorry.
I have designed two buttons.One button for selecting the file and another button for to open the selected file.I have selected the file correctly and the file path also retrieved.But i cant open the particular file directly by the file path.Any one I have tried something like this
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
+ selectedFilePath);
intent.setDataAndType(uri, "text/csv");
startActivity(Intent.createChooser(intent, "Open folder"));
First, ACTION_GET_CONTENT does not accept a Uri as input.
Second, ACTION_GET_CONTENT has nothing to do with opening a file. Presumably, you should be using ACTION_VIEW.
Third, the value that you are passing to Uri.parse() is not a String form of a Uri.
Also, I would expect few Android devices to have an ACTION_VIEW activity for text/csv content.
I am working with pdf files in my android app.
In a Alert Dialog pressing "Yes" should open the pdf file location in default file manager app.
I tried with this but it always open a chooser. Even-though it(ES File Explorer) opens with "Choose Path" dialog not the folder in the app as normal way of accessing folder.
So, is there possible to open directly the content of folder in "Default File Manager"? Or can open with chooser , from that selected app it should show the pdf file chooser when selecting the pdf file?.
Below is my try to achieve this.
public void openFolder(String filePath)
{
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(filePath.substring(0, filePath.lastIndexOf("/")));
intent.setDataAndType(uri, "*/*");//tried with application/pdf and file/*
intent.addCategory(Intent.CATEGORY_OPENABLE);
PackageManager pm = context.getPackageManager();
List<ResolveInfo> apps =
pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (apps.size() > 0)
startActivity(intent);//Intent.createChooser(intent, "Open folder"
}
Edited
And I tried with ACTION_PICK too. Its directed to specific folder of default file manager.But from there selecting a file not open the chooser (pdf viewer list dialog).
I am trying to open a .doc file from my SD card using Polaris Viewer.
I keep on getting a message saying "This document cannot be opened".
weird thing is that I CAN open it from elsewhere.
I have ES File Explorer on my phone and I can open through there. It does it via Polaris Viewer so the file is obviously okay.
The only thing I can think of is that I have a problem with my intent.
Is there any way to see exactly what intent ES File Explorer sent?
This is my code (textOpenUri is a full path name of the file to be opened):
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(textOpenUri, "application/msword");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
I did a small test (just to make sure it is not defaulting to some other app) using:
List<ResolveInfo> list = getActivity().getPackageManager().queryIntentActivities(intent,0);
and I get back Polaris as the only app that can deal with the intent.
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromFile(file);
intent.setDataAndType(uri, "application/msword");
this.startActivity(intent);
startActivity(intent);