Hanuman
Hanuman

Reputation: 968

When I am browsing a file using intents it's not going to File Manager?

When i click on the Browse button i have added below code:

Intent intent = new Intent(Intent.ACTION_VIEW);    
intent.setType("*/*");
startActivityForResult(intent, CHOOSE_FILE_REQUESTCODE);

It shows FileManager in some devices like Redmi,Asus,Micromax.But it is not showing in Samsung phones,it's not going to file manager

How to get FileManager in Samsung phones to select a file?

Upvotes: 0

Views: 585

Answers (2)

J.K
J.K

Reputation: 2393

try this is working for me

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
startActivityForResult(intent , CHOOSE_FILE_REQUESTCODE);

for Samsung Devices

String manufactures = android.os.Build.MANUFACTURER;
    if(manufactures.equalsIgnoreCase("samsung")){
        Intent intent = new Intent("com.sec.android.app.myfiles.PICK_DATA");              
        intent.putExtra("CONTENT_TYPE", "*/*");
        startActivityForResult(intent, CHOOSE_FILE_REQUESTCODE); 
    } 

Upvotes: 3

Kirill Shalnov
Kirill Shalnov

Reputation: 2216

Replace

Intent intent = new Intent(Intent.ACTION_VIEW); 

as

Intent intent = new Intent(Intent.GET_CONTENT);

EDIT

@Hanuman i think that single solution that fits all models doesn't exist, all intents with "actions" have to be processed by choosers. If you use >= 4.4 devices, I recommend Storage Access Framework

Upvotes: 1

Related Questions