Android file associations don't work (intent filter, by extension)
I am trying to link my application with the vrtci file extension but it doesn't work. I have been browsing the internet to figure out what I am doing wrong and nothing helped. Here is a section of my AndroidManifest.xml:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:theme="@style/Theme.AppCompat.Light">
<activity
android:name=".MainCardActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".CardInstaller" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:pathPattern=".*\\.vrtci" />
<data android:mimeType="application/octet-stream" />
</intent-filter>
<!-- For http -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.vrtci" />
<data android:pathPattern=".*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.vrtci" />
<data android:mimeType="*/*" />
</intent-filter>
<!-- For https -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="https" />
<data android:host="*" />
<data android:pathPattern=".*\\.vrtci" />
<data android:pathPattern=".*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.vrtci" />
<data android:mimeType="*/*" />
</intent-filter>
<!-- For file browsers and google drive -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.vrtci" />
<data android:pathPattern=".*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.vrtci" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
</application>
+3
source to share
1 answer
So, I just found a solution that did it for me.
Create an intent filter with the "content" schema and don't specify a host element at all.
<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:scheme="content" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.vrtci" />
<data android:pathPattern=".*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.vrtci" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.vrtci" />
</intent-filter>
+1
source to share