Pick a file in Android without any file manager installed -


i tried picking file internal or external storage code below:

intent intent = new intent(intent.action_get_content); intent.settype("file/*"); startactivityforresult(intent, 1); 

of course has onactivityresult method, , it's not problem. works fine in modern phones or phones have file manager installed. old 1 no file manager throws

android.content.activitynotfoundexception: no activity found handle intent { act=android.intent.action.get_content typ=file/* }

i tried switching action_pick no luck. tried intent.settype("*/*");, didn't crash popup ask action (videos, contacts,...) not true. want pick file not specified type.

i don't want use other file manager pick file. there anyway can through this?

i believe having error explained, makes solution easier. let me explain you:

you're starting implicit intent. means it's intent know want happen (use select file) , don't care application it.

the error you're encountering system telling (the developer), there's no application installed capable of doing (neither system nor 3rd party). there's no 1 capable of handling action want.

so have 2 options can see:

  • try-catch error

.

try {    startactivityforresult(intent, 1); } catch (activitynotfoundexception e) {    // maybe should show toast user here?    toast.maketext(context, "you need install file picker", toast.length_short).show();    // or maybe redirect 3rd party app know works    startintent(new intent(uri.parse("https://play.google.com/... app } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -