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 }
- you can find library or code pick file inside own app: http://bit.ly/1n1fzbo
Comments
Post a Comment