Android - get file path of a selected pdf, doc, ppt or xls in my app -
Android - get file path of a selected pdf, doc, ppt or xls in my app -
i developing android application.
my aim:
if user open pdf, doc, ppt or xls files in folder within sdcard (or) dropbox (or) email etc..., must navigate app(in app, process based on files selected).
what did:
if user click on pdf file, can filepath , navigate app. have done next code.
code snippet:
in androidmanifest.xml, have added next code:
<activity android:name="com.openwith.openwithactivity" > <intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.browsable" /> <data android:scheme="file" /> <data android:mimetype="*/*" /> <data android:scheme="http" android:host="*" android:pathpattern=".*\\.pdf" /> <data android:scheme="https" android:host="*" android:pathpattern=".*\\.pdf" /> <data android:scheme="content" android:host="*" android:pathpattern=".*\\.pdf" /> <data android:scheme="file" android:host="*" android:pathpattern=".*\\.pdf" /> </intent-filter> </activity>
in openwithactivity.java
import android.annotation.suppresslint; import android.app.activity; import android.content.intent; import android.net.uri; import android.os.bundle; import android.webkit.webview; public class openwithactivity extends activity { @suppresslint("setjavascriptenabled") @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_openwith); intent intent = getintent(); uri info = intent.getdata(); if (data != null) { string filepath = data.getpath(); } } }
what need:
i getting pdf file's path. if want doc, ppt , xls file's path, need add together in androidmanifest.xml?
i have searched in internet. didn't clear documents (or) tutorials. can hep me this?
add same intent-filter entries other file types did pdf.
<data android:scheme="http" android:host="*" android:pathpattern=".*\\.ppt" /> <data android:scheme="https" android:host="*" android:pathpattern=".*\\.ppt" /> <data android:scheme="content" android:host="*" android:pathpattern=".*\\.ppt" /> <data android:scheme="file" android:host="*" android:pathpattern=".*\\.ppt" /> <data android:scheme="http" android:host="*" android:pathpattern=".*\\.xls" /> <data android:scheme="https" android:host="*" android:pathpattern=".*\\.xls" /> <data android:scheme="content" android:host="*" android:pathpattern=".*\\.xls" /> <data android:scheme="file" android:host="*" android:pathpattern=".*\\.xls" /> <data android:scheme="http" android:host="*" android:pathpattern=".*\\.doc" /> <data android:scheme="https" android:host="*" android:pathpattern=".*\\.doc" /> <data android:scheme="content" android:host="*" android:pathpattern=".*\\.doc" /> <data android:scheme="file" android:host="*" android:pathpattern=".*\\.doc" />
and images, should do:
<intent-filter> <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.browsable" /> <data android:mimetype="image/*" android:scheme="http" android:host="*" /> <data android:mimetype="image/*" android:scheme="https" android:host="*" /> <data android:mimetype="image/*" android:scheme="content" android:host="*" /> <data android:mimetype="image/*" android:scheme="file" android:host="*" /> </intent-filter>
android android-intent open-with browsable
Comments
Post a Comment