简体   繁体   中英

SHARE INTENT Intent.createChooser: How to display all installed file browser apps?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM