Dave Hubbard
Dave Hubbard

Reputation: 489

App not showing as option from file explorer - Intent-filter not working

I have tried every suggestion out here with no luck. I simply want my app to receive the intent if a user clicks on a text file from a file explorer like the Samsung 'My Files' app. It just does not show up on the list of available apps.

My activity is specified like this at present:

<activity
        android:name=".ImportActivity"
        android:label="@string/title_activity_import"
        android:parentActivityName=".MainActivity"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter android:label="import">
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.PICK" />
            <action android:name="android.intent.action.PICK_ACTIVITY" />
            <action android:name="android.intent.action.GET_CONTENT" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
            <data android:scheme="file" android:host="*" android:pathPattern=".*\\.txt" />
            <data android:scheme="content" android:host="*" android:pathPattern=".*\\.txt" />
        </intent-filter>
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.hubbardsoftware.racetac.MainActivity" />
    </activity>

I put a 'test.txt' file in my download folder that just has a line of text in it. Navigate to it with 'My Files', tap it, and get an option to open with 'HTML Viewer', 'Chrome', and 'Hancom Office 2014'. My app is called 'RaceTac' and it just doesn't show up. The app is working fine otherwise. I have tried simpler versions of the filter too. It's staring me in the face I know it.

Thanks, Dave

Upvotes: 0

Views: 1728

Answers (2)

Javaria
Javaria

Reputation: 1

I am working with pdf opening in app i am getting my app for the "open with" option in a app chooser but when i try "send file" option i am unable to get my app in a chooser Anybody has any idea which action observe this action for "send file" option?

my intent filter look like this

<activity
            android:name=".modules.payments.view.PaymentActivity"
            android:configChanges="locale"
            android:parentActivityName=".modules.home.view.HomeActivity"
            android:theme="@style/AppTheme.NoActionBar"
            android:windowSoftInputMode="adjustResize" >

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.PICK" />
                <action android:name="android.intent.action.PICK_ACTIVITY" />
                <action android:name="android.intent.action.GET_CONTENT" />
                <category android:name="android.intent.category.DEFAULT" />
                
                <data android:mimeType="application/pdf"/>
                <data android:scheme="file"/>
                <data android:scheme="content" />
            </intent-filter>

            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="no.dnb.bmpuls.modules.home.view.HomeActivity" />

</activity>

Upvotes: 0

Michael B.
Michael B.

Reputation: 3430

Remove the host and pathPattern, from the documentation it's not needed

<activity
        android:name=".ImportActivity"
        android:label="@string/title_activity_import"
        android:parentActivityName=".MainActivity"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter android:label="import">
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.PICK" />
            <action android:name="android.intent.action.PICK_ACTIVITY" />
            <action android:name="android.intent.action.GET_CONTENT" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
            <data android:scheme="file" />
            <data android:scheme="content" />
        </intent-filter>
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.hubbardsoftware.racetac.MainActivity" />
    </activity>

developer.android.com/guide/components/intents-filters.htmll

Upvotes: 4

Related Questions