首页 > 解决方案 > 使用我的 android 应用程序打开特定文件

问题描述

当我单击扩展名为“play”(someFileName.play)的文件时,我试图打开我的 android 应用程序。
我的问题是,我单击哪种文件并不重要,它提供了使用我的应用程序打开它的选项。
这是我的“Manifest.xml”:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.play">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:launchMode="singleTask"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
         <!-- custom file start -->
        <intent-filter
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name">
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.EDIT" />
            <category android:name="android.intent.category.DEFAULT" />
            <!-- change custom file extension -->
            <data android:mimeType="*/*" />
            <data android:host="*" />
            <data android:pathPattern=".*\\.play" />
        </intent-filter>
        <!-- custom file end -->
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>
</manifest>


需要帮助修复它,请帮助。

标签: androidandroid-manifestreact-native-androidmanifest

解决方案


尝试更改为:

        <!-- change custom file extension -->
        <data android:mimeType="*/*" 
              android:host="*" 
              android:pathPattern=".*\\.play" />

推荐阅读