Android(清单)-在后台在应用中打开意图,而不是在发件人中

时间:2018-09-12 17:39:44

标签: android delphi android-intent android-manifest firemonkey

我设法编辑了清单文件,以便我的Android应用可以通过意图从消息传递应用接收具有特定文件扩展名的文件:

        <intent-filter>
            <!-- needed for properly formatted email messages -->
            <data
                android:scheme="content"
                android:mimeType="application/vnd.eureka"
                android:pathPattern=".*\\.cw" />
            <!-- needed for mangled email messages -->
            <data
                android:scheme="content"
                android:mimeType="application/eureka"
                android:pathPattern=".*\\.cw" />
            <!-- needed for mangled email messages -->
            <data
                android:scheme="content"
                android:mimeType="application/octet-stream"
                android:pathPattern=".*\\.cw" />
            <data
                android:scheme="content"
                android:mimeType="*/*"
                android:pathPattern=".*\\.cw" />

            <action android:name="android.intent.action.VIEW" />

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

        <!-- Register to handle file opening -->
        <intent-filter>
            <data android:scheme="file"
                  android:mimeType="*/*"
                  android:pathPattern=".*\\.cw"
                  android:host="*"/>

            <action android:name="android.intent.action.VIEW" />

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

当我的应用程序在应该接收文件之前未运行或者意图是来自WhatsApp或GMail应用程序时,此方法效果很好。

但是,当应用程序已经在后台运行并且您尝试从Telegram Messenger打开文件时,似乎在Telegram内部创建了该应用程序的第二个实例(应用程序切换器显示了该应用程序的两个实例:一个标记为“ Eureka” /应用名称和一个标记为Telegram的名称)。这将导致该应用程序停止响应。甚至在新项目中也会发生这种情况,因此我怀疑Delphi应用程序不支持具有多个实例(我正在西雅图的Delphi 10中开发)。

我希望在已经在后台运行的实例中打开该意图,以避免出现此问题。

LaunchMode已经设置为“ singleTask”,我将其更改为“ singleInstance”,但未成功。

0 个答案:

没有答案