
我想使用一个Intent过滤器,当在fileexplorer中单击一个zip文件时,它会打开应用程序
所以我必须使用哪种mimetype?
以及获得路径的代码?
<activity androID:name=".App" androID:label="@string/app_name" > <intent-filter> <action androID:name="androID.intent.action.SEND" /> <category androID:name="androID.intent.category.DEFAulT" /> <data androID:mimeType="text/plain" /> </intent-filter> </activity>Java的代码:
Intent intent = getIntent(); // To get the action of the intent use String action = intent.getAction(); if (action != Intent.ACTION_SEND) { throw new RuntimeException("Should not happen"); } // To get the data use Uri data = intent.getData(); URL url; try { url = new URL(data.getPath()); } catch (MalformedURLException e) { // Todo auto-generated catch block e.printstacktrace(); }解决方法:
您可以使用以下IntentFilter:
<intent-filter> <action androID:name="androID.intent.action.VIEW"/> <category androID:name="androID.intent.category.DEFAulT"/> <data androID:mimeType="application/zip"/></intent-filter>当您的Activity启动时,它有一个数据URI,您可以从中获取zip文件:
file zip = new file(getIntent().getData().getPath()); 总结 以上是内存溢出为你收集整理的Android Intent Filter zip全部内容,希望文章能够帮你解决Android Intent Filter zip所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)