当我尝试分享来自 Google 的图像时,我的 Kotlin 应用程序不出现

问题描述 投票:0回答:1

我通过观看互联网上的一些教程来学习 Kotlin。我尝试通过转到 Google 并选择“共享图像”来接收我的应用程序中的图像,但我的应用程序没有显示为选项。

我在 Google、YouTube、ChatGPT、StackOverflow 和 Android Developers 上搜索过解决方案,但还没有找到解决方案。我正在使用 API 34。

这是我的清单。据我了解,我只需要添加 即可接收图像,对吧?我还检查了我的应用程序是否需要任何权限,这就是我添加 行的原因。我查看了“设置”->“应用程序”->“权限”,但它已被禁用。最后,我尝试在另一个 AVD(API 33)上运行我的应用程序,但它不起作用。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Fundamentals"
        tools:targetApi="31">

        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="image/*" />
            </intent-filter>
        </activity>

        <activity
            android:name=".SecondActivity"
            android:exported="false">
        </activity>

    </application>

    <queries>
        <intent>
            <action android:name="android.intent.action.SEND" />
            <data android:mimeType="text/plain" />
        </intent>
    </queries>
</manifest>
java android kotlin android-manifest
1个回答
0
投票

你的代码对我来说看起来不错,我认为问题出在其他地方。

当您使用 Google 应用程序并长按图像时,您可以选择共享该图像:

不过,您

实际上分享的只是该图像的链接

如您所见,标题显示“共享链接”,您甚至可以看到该链接。

链接只是简单的纯文本。如果您希望您的应用程序接收此类链接,您需要将意图过滤器的

data

 标签调整为:

<data android:mimeType="text/plain" />
我认为您无法使用 Google 应用程序发送实际图像,但您可以尝试其他应用程序,例如相机。使用原始意图过滤器,您的应用程序应该显示为目标。

© www.soinside.com 2019 - 2024. All rights reserved.