I'm learning Kotlin by watching some tutorials on the internet. I tried to receive images in my app by going to Google and selecting "Share Image," but my app does not appear as an option.
I've searched for a solution on Google, YouTube, ChatGPT, StackOverflow, and Android Developers, but I haven't found a solution. Im using API 34.
Here is my manifest. As I understand it, I only need to add the <intent-filter> to receive images, right? I also checked if my app needs any permissions, which is why I included the <uses-permission> line. I looked in Settings -> App -> Permissions, but it was disabled. Lastly, I tried running my app on another AVD (API 33), but it didn't work.
<?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>
You code looks good to me, I think the problem is somewhere else.
When you use the Google app and long-press on an image you can select to share that image:
What you are actually sharing, though, is just a link to that image:
As you can see, the title says "Sharing link" and you can even see the link.
Links are just simple, plain text. If you want your app to receive such links you need to adjust your intent filter's data
tag to this:
<data android:mimeType="text/plain" />
I don't think you can send actual images with the Google app, but you can try another app, like your camera. With the original intent filter your app should then appear as a target.