我是靠谱客的博主 聪明板栗,这篇文章主要介绍将应用添加到打开方式,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<intent-filter tools:ignore="AppLinkUrlError"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="application/*" /> <!--<data android:mimeType="application/pdf" />--> <!--<data android:mimeType="application/vnd.ms-excel" />--> </intent-filter> Intent intent = getIntent(); String path = null; if (Intent.ACTION_VIEW.equals(intent.getAction())) { String dataString = intent.getDataString(); String urlDecode = EncodeUtils.urlDecode(dataString); try { URL url = new URL(urlDecode); path = url.getFile(); } catch (MalformedURLException e) { Log.d(TAG, "onCreate: URL格式化失败"); } Log.d(TAG, "onCreate: 被微信调起 = " + path); } Uri uri = Uri.fromFile(new File(mUrlPath)); Intent intent = new Intent(Intent.ACTION_SEND); intent.setAction(Intent.ACTION_SEND); // 分享单个文件 intent.setAction(Intent.ACTION_SEND_MULTIPLE); // 分享多个文件 intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList); // 分享的多媒体(多) intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); intent.putExtra(Intent.EXTRA_STREAM, uri); // 分享的多媒体(单) intent.putExtra(Intent.EXTRA_SUBJECT, "测试标题"); // 添加分享内容标题 intent.putExtra(Intent.EXTRA_TEXT, "测试内容"); // 添加分享内容 startActivity(Intent.createChooser(intent, "分享到")); // 分享Dialog的标题

最后

以上就是聪明板栗最近收集整理的关于将应用添加到打开方式的全部内容,更多相关将应用添加到打开方式内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(106)

评论列表共有 0 条评论

立即
投稿
返回
顶部