0

I want to display all installed file browser apps when the user press a button "browse files" in my app, but without passing it any file, I just want to open a file browser. Also I don't want to wait for a file chooser or any other result. I just want to display the user apps installed for browse his files.

I tried this:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivity(Intent.createChooser(intent, getString(R.string.select_file_browser)));

It should display to the user all the file explorer apps installed in the device, which has three, but is not displaying them. The device is just opening the default "FILES" google default app installed in the device.

How can I solve this?

Is Intent.ACTION_GET_CONTENT the correct intent for this purpose?

halfer
  • 19,824
  • 17
  • 99
  • 186
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
  • No. You better try with ACTION_VIEW. – blackapps Apr 25 '21 at 10:29
  • @blackapps if I change ACTION_GET_CONTENT with ACTION_VIEW then I got a empty app selection dialog with the text "no apps can perform this action". Should I change something more? – NullPointerException Apr 25 '21 at 12:05
  • Post complete code to begin with. Try other mime types. I only know a solution for an Android 11 device using the Files app. I dont know how to display all file browsers. – blackapps Apr 25 '21 at 12:08
  • @blackapps the complete code is already posted in my question, should I change something? – NullPointerException Apr 25 '21 at 12:11
  • DO you see ACTION_VIEW somewher? I dont. Did you try other mime types? I dont see you doing so. – blackapps Apr 25 '21 at 12:13
  • @blackapps maybe you didn't read my first coment, I already changed ACTION_GET_CONTENT with ACTION_VIEW then I got a empty app selection dialog with the text "no apps can perform this action". Should I change something more? I just wanna open a file browser, don't wanna receive a selected file or something similar, don't wanna get a return from the file browser. I don't know what mime type should I test to achieve it. – NullPointerException Apr 25 '21 at 12:14

1 Answers1

0

The package name of the Files app (on modern Android devices available) is

com.google.android.apps.nbu.files

You can obtain a launch intent for a package name and then use start activity.

String packageName = "com.google.android.apps.nbu.files";

Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);

startActivity(intent);

Be shure to catch a lot of possible exceptions.

Knowing a package name you can start every app in this way.

blackapps
  • 8,011
  • 2
  • 11
  • 25