一、将自己的app添加到微信和QQ的文件打开选择其他应用列表中
通过,Android Studio 控制台日志看,微信打开其他应用传递的Intent对象
Activity_launch_request time:659490872 intent:Intent { act=android.intent.action.VIEW
dat=content://com.tencent.mm.external.fileprovider/external/tencent/MicroMsg/Download/新建文本文档 (2).txt
typ=text/plain flg=0x10000001 pkg=com.android.htmlviewer }
QQ打开其他应用的Intent
{act=android.intent.action.VIEW cat=[android.intent.category.DEFAULT]
dat=content://com.tencent.mobileqq.fileprovider/external_files/storage/emulated/0/
Tencent/QQfile_recv/OPPO云真机日志文件201908281538.txt
typ=text/plain flg=0x1 pkg=com.android.htmlviewer
cmp=com.android.htmlviewer/.HTMLViewerActivity (has extras)} from uid 10162
可以看到看到
Action:android.intent.action.VIEW
data:content://com.tencent.mm.external.fileprovider/external/tencent/MicroMsg/Download/新建文本文档 (2).txt
mimeType: text/plain
pkg :包名 com.android.htmlviewer
flg : 0x10000001
根据以上信息配置 intent-filte
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content"/>
<!-- 允许所有类型文件-->
<data android:mimeType="*/*" />
</intent-filter>
二、将自己的app作为其他应用提供给其他app使用
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<!-- 允许所有类型文件-->
<data android:scheme="file"/>
</intent-filter>
具体的scheme配置参考:scheme配置介绍