因此,我正在开发一个Android应用程序,并使用Cordova对其进行了实现。该应用程序运行良好,但是我遇到了一个问题,即只能在我们自己的自定义文件扩展名的项目文件的“打开方式”上下文菜单中提供它。想法是您可以点击其中一个项目文件(由应用程序生成),然后启动应用程序并打开项目。 到目前为止,我只能通过使其适用于所有mimeTypes来使其工作。这意味着,如果您点击任何文件,它将为我们的应用程序提供打开它的选项。似乎忽略了我给它的pathPattern中的文件扩展名。
这是我用来尝试将文件类型注册到我的应用程序的插件:https://github.com/j3k0/cordova-plugin-openwith
我曾尝试创建自定义的mimeType,例如“ application / customType”,但这通常只会导致文件浏览器提示没有应用程序可以打开该文件。
我还尝试放置多个pathPatterns来解决可能存在另一个“。”的问题。它需要逃脱在路径的某个地方。
有什么想法在这里做什么?我希望它优先考虑文件扩展名而不是mimeType,但是我想Android不能那样工作。
我的config.xml中的意图过滤器。
<platform name="android">
<allow-intent href="market:*" />
<config-file parent="./application/activity"
target="AndroidManifest.xml">
<intent-filter android:name="com.company.name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.customExtension" />
</intent-filter>
</config-file>
</platform>
config.xml中的openWith插件:
<plugin name="cc.fovea.cordova.openwith" spec="^1.2.0">
<variable name="ANDROID_MIME_TYPE" value="text/plain" />
<variable name="ANDROID_EXTRA_ACTIONS" value=" " />
</plugin>