I have tried to register a new file association using the suggestions answered in this question
I want to open the main Activity
of the app if the user try to open the registered file type
According the accepted answer in the Manifest
I have tried this code
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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:scheme="http" android:host="*"
android:pathPattern=".*\\.myfilextension" />
<data android:scheme="https" android:host="*"
android:pathPattern=".*\\.myfilextension" />
<data android:scheme="content" android:host="*"
android:pathPattern=".*\\.myfilextension" />
<data android:scheme="file" android:host="*"
android:pathPattern=".*\\.myfilextension" />
</intent-filter>
</activity>
but the .myfilextension
seems not correctly associated, since if I try to open a file sample.myfilextension
nothing happens.
So I have tried
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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:scheme="http" />
<data android:scheme="https" />
<data android:scheme="ftp" />
<data android:scheme="file" />
<data android:host="*" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.myfilextension" />
</intent-filter>
</activity>
With this code, if I try to open a file .myfilextension
and the App has been launched and is running in background everything works fine, but if the app is closed when I try to open the file, the app try to start but hangs, in the emulator hangs on "wait for debugger" soI cannot understand the cause of the issue.
How could I fix this?
The second sample code should work.
The problem seems related to the Emulator that cannot attach the debugger.
Try to follow these steps:
-Close the Emulator
-Go to AVD manager and recreate the emulator again
-Start the emulator and try to run the app
Alternatively try to run the app on a real device.