Make my android app appear in the share list [dupl

2019-01-23 00:50发布

问题:

This question already has an answer here:

  • How to make my Android app appear in the share list of another specific app 5 answers

How do i make my application appear here? :

some informations led me to put this code on my Manifest (See code below) but it doesn't work. The thing is if i want to share an image from my gallery, i want to see my app on the list of app on the share list. Any pointers? please help.

<activity
        android:name="com.my.package.MyIntent"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.ALL_APPS" />

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

            <data android:mimeType="text/plain" />
        </intent-filter>
    </activity>

Thank you :)

回答1:

Try this way

       <activity
        android:name="yourActivity"
        android:icon="@drawable/ic_launcher"
        android:label="test">
        <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>

        <intent-filter>
            <action android:name="android.intent.action.SEND" />

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

            <data android:mimeType="text/plain" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.SEND_MULTIPLE" />

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

            <data android:mimeType="image/*" />
        </intent-filter>
    </activity>

For more information go to Receiving Simple Data from Other Apps and Sending Simple Data to Other Apps



回答2:

Intent Filters - Android Developers Information:

Note: In order to receive implicit intents, you must include the CATEGORY_DEFAULT category in the intent filter. The methods startActivity() and startActivityForResult() treat all intents as if they declared the CATEGORY_DEFAULT category. If you do not declare this category in your intent filter, no implicit intents will resolve to your activity.

        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
            <data android:mimeType="image/*" />
        </intent-filter>