【问题标题】:Intent-filter abnormal behavior with samsung file browser使用三星文件浏览器的意图过滤异常行为
【发布时间】:2016-08-29 11:50:54
【问题描述】:

我正在为我的应用程序的特定扩展 (.infi) 创建一个意图过滤器。它可以与 ES 文件资源管理器和 Solid Explorer 一起正常工作。但是,当我使用三星默认文件资源管理器(设备 Galaxy Tab S2)打开文件时,它会显示一条奇怪的消息“没有应用程序来执行此操作”,在其他设备上(注 4)它尝试使用 Adob​​e Reader 打开文件但出现错误信息。这是清单文件中的代码:

<activity android:name=".ImportCollections">
        <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:mimeType="*/*" />
            <data android:pathPattern=".*\\.infi" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="http" />
            <data android:host="*" />
            <data android:mimeType="*/*" />
            <data android:pathPattern=".*\\.infi" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="content" />
            <data android:mimeType="application/octet-stream" />
            <data android:pathPattern=".*\\.infi" />
            <data android:host="gmail-ls" />
        </intent-filter>


    </activity>

【问题讨论】:

  • 你试过添加吗?

标签: android android-intent intentfilter


【解决方案1】:

为了将来的参考,我寻找了另一个正确实现此功能的开源应用程序。这些家伙做得很好:

https://github.com/ankidroid/Anki-Android/blob/develop/AnkiDroid/src/main/AndroidManifest.xml

这是我的有效代码(只需将“infi”替换为您的自定义扩展)

<activity
        android:name=".ImportCollections"
        android:launchMode="singleTask"
        android:parentActivityName=".ManageCollections">
        <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:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.infi"
                android:scheme="http" />
            <data
                android:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.infi"
                android:scheme="https" />
            <data
                android:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.infi"
                android:scheme="content" />
            <data
                android:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.infi"
                android:scheme="file" />
        </intent-filter>
        <!-- MIME type matcher for .infi files coming from providers like gmail which hide the file extension -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:mimeType="application/infi" />
            <data android:mimeType="application/x-infi" />
            <data
                android:mimeType="application/octet-stream"
                android:scheme="content" />
            <data
                android:mimeType="application/zip"
                android:scheme="content" />
        </intent-filter>
    </activity>

【讨论】:

  • 嗨,您是否让三星我的文件打开了您的应用程序?你知道钓点在哪里吗?我的应用从浏览器和其他文件管理器中打开,但不是从三星我的文件中打开。
  • repo 不见了,你能详细说明你是如何解决这个问题的吗?
  • 在这里查看我的评论:stackoverflow.com/questions/50407193/… 不幸的是,这不适用于运行 Android 8 的三星 S8。
猜你喜欢
  • 2012-06-14
  • 2021-12-25
  • 1970-01-01
  • 1970-01-01
  • 2013-09-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多