简体   繁体   English

应用程序未显示为文件浏览器中的选项-意图过滤器不起作用

[英]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. 我只是希望如果用户从文件浏览器(如Samsung“我的文件”应用程序)中单击文本文件,我的应用程序就会收到意图。 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. 我在下载文件夹中放了一个“ test.txt”文件,里面只有一行文字。 Navigate to it with 'My Files', tap it, and get an option to open with 'HTML Viewer', 'Chrome', and 'Hancom Office 2014'. 使用“我的文件”导航到它,点击它,然后选择打开“ HTML Viewer”,“ Chrome”和“ Hancom Office 2014”。 My app is called 'RaceTac' and it just doesn't show up. 我的应用程序名为“ RaceTac”,它没有显示。 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 谢谢戴夫

Remove the host and pathPattern, from the documentation it's not needed 从不需要的文档中删除host和pathPattern

<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.html l developer.android.com/guide/components/intents-filters.html l

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM