首页 > 解决方案 > 如何在尝试打开具有特定扩展名的文件时让 android os 建议一个颤振应用程序,例如:.torrent

问题描述

在安卓设备中打开文件时,操作系统会根据文件的扩展名推荐兼容的应用程序。(例如:打开.torrent文件时,操作系统会自动建议已安装的 torrent 客户端)。当打开特定格式的文档时,有没有办法让操作系统建议安装的颤振应用程序?

此外,通过特定文件打开应用程序应触发应用程序中的回调以处理相关事件。

标签: androidflutterdartoperating-system

解决方案


检查这个文档。https://flutter.dev/docs/get-started/flutter-for/android-devs#how-do-i-handle-incoming-intents-from-external-applications-in-flutter

<activity
  android:name=".MainActivity"
  android:launchMode="singleTop"
  android:theme="@style/LaunchTheme"
  android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
  android:hardwareAccelerated="true"
  android:windowSoftInputMode="adjustResize">
  <!-- ... -->
  <intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
  </intent-filter>
</activity>

android:mimeType扩展列表


推荐阅读