Register my App with <intent-filter> not working

27 views Asked by At

I'm having trouble opening an XML from the "Google Files App" file to do internal processing in my app, despite using an intent filter in the manifest file.

Here's what I've done:

  • I use an XML file named data.xml in the Download directory of my app.
  • I added the following intent filter to the from my MainActivity element in my app's manifest file:
<activity
                android:name=".MainActivity"
                android:label="@string/app_name"
                android:exported="true"
                android:theme="@style/AppTheme.NoActionBar">

            <!-- Main -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>

            <!-- Register XML -->
            <intent-filter>
                <action android:name="android.intent.action.OPEN_DOCUMENT" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="application/xml" />
            </intent-filter>
            
        </activity>

Here are some things I've tried:

  • I made sure that the XML file is well-formed.
  • I made sure that the intent filter is correct.
  • I tried using different MIME types.

Nothing has worked so far. I'm working on an app with SDK 33.

2

There are 2 answers

9
CommonsWare On

Replace android.intent.action.OPEN_DOCUMENT with android.intent.action.VIEW.

0
lupaulus On

Seems that the AndroidManifest.xml did not be updated or notify the system about the <intent-filter>, if the app is reinstalled from Android Studio.

To make it work, I remove my App completely from my device and reinstall it.