ANDROID - Intent to launch app as a file manager
-
19-06-2021 - |
Pregunta
I am building an app using Phonegap
Build. HTML,CSS,JS
...
I want the app to come up when the user clicks something that needs a file manager.
I know, I have to put something in the AndroidManifest, but I have no idea what... Any help?
Another Example: Let's say i am on my home screen (APEX) and want to select a new icon. When I click the icon a list comes up with all the apps I can use to find the icon. These apps include Astro, Box, SolidExplorer, Gallery, and more... How can I get my app to come up on that list?
Solución
You need to declare your activity
in manifest file with such intent-filter with specific data elements.
for ex:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.pdf" />
</intent-filter>
Otros consejos
Intent.ACTION_GET_CONTENT
may help.
Here is an example of launching a file chooser with image type files.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("image/*"); // choose any image
intent.addCategory(Intent.CATEGORY_OPENABLE);
Intent chooserIntent = Intent.createChooser(intent, "File chooser");
startActivityForResult(chooserIntent, REQUEST_CODE);