<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的标题
将应用添加到打开方式
最新推荐文章于 2023-02-24 19:35:36 发布