如何创建文件以匹配自定义意图过滤器以打开我的应用程序?
How create file to match custom intent filter to open my app?
我已经阅读了关于这个主题的数千个问题,但没有找到任何有用的答案。
我必须创建一个文件(包含字符串),从下载应用程序或文件管理器中点击它我想打开我的应用程序。 (只是我的应用程序)
我可以根据需要创建文件:文件名、文件扩展名或 mime 类型
每次尝试都失败了:或者我的应用拦截了任何文件或者我的应用没有拦截我的文件
所以,我的问题是:
1) 如何根据需要创建文件?
2) 如何为该文件创建意图过滤器?
这么多
有时候androidsdk做的不好,这是个案例:
将 Nexus 6p 与 Stock 7.1.2 结合使用,点击下载的文件会根据您所在的应用程序生成不同的意图。我强调了一个事实,即设备没有外部应用程序并且固件是库存的。下面是不同系统应用生成的intent列表
来自下载
act=android.provider.action.MANAGE_DOCUMENT
dat=content://com.android.providers.downloads.documents/document/152
cmp=com.android.providers.downloads.ui/.TrampolineActivity
来自最近(内部下载)
act=android.intent.action.VIEW
dat=content://com.android.providers.downloads.documents/document/152
typ=application/json
来自官方 android 文件资源管理器(在设置内)
act=android.intent.action.VIEW
dat=content://com.android.externalstorage.documents/document/primary:Download/20-conversation.nc
typ=application/octet-stream
我发现拦截所有意图的唯一解决方案是这个(我的文件是 xxxx.nc 并包含一个 json 字符串):
<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:host="*"
android:mimeType="*/*"
android:pathPattern=".*\.nc"
android:scheme="content"/>
</intent-filter>
<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:host="*"
android:mimeType="application/json"
android:scheme="content"/>
</intent-filter>
希望第三方文件管理器不要制造更多的熵
我已经阅读了关于这个主题的数千个问题,但没有找到任何有用的答案。
我必须创建一个文件(包含字符串),从下载应用程序或文件管理器中点击它我想打开我的应用程序。 (只是我的应用程序)
我可以根据需要创建文件:文件名、文件扩展名或 mime 类型
每次尝试都失败了:或者我的应用拦截了任何文件或者我的应用没有拦截我的文件
所以,我的问题是:
1) 如何根据需要创建文件?
2) 如何为该文件创建意图过滤器?
这么多
有时候androidsdk做的不好,这是个案例:
将 Nexus 6p 与 Stock 7.1.2 结合使用,点击下载的文件会根据您所在的应用程序生成不同的意图。我强调了一个事实,即设备没有外部应用程序并且固件是库存的。下面是不同系统应用生成的intent列表
来自下载
act=android.provider.action.MANAGE_DOCUMENT
dat=content://com.android.providers.downloads.documents/document/152
cmp=com.android.providers.downloads.ui/.TrampolineActivity
来自最近(内部下载)
act=android.intent.action.VIEW
dat=content://com.android.providers.downloads.documents/document/152
typ=application/json
来自官方 android 文件资源管理器(在设置内)
act=android.intent.action.VIEW
dat=content://com.android.externalstorage.documents/document/primary:Download/20-conversation.nc
typ=application/octet-stream
我发现拦截所有意图的唯一解决方案是这个(我的文件是 xxxx.nc 并包含一个 json 字符串):
<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:host="*"
android:mimeType="*/*"
android:pathPattern=".*\.nc"
android:scheme="content"/>
</intent-filter>
<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:host="*"
android:mimeType="application/json"
android:scheme="content"/>
</intent-filter>
希望第三方文件管理器不要制造更多的熵