How to add app to “Share via” list for camera picture on Android

后端 未结 2 488
予麋鹿
予麋鹿 2020-12-04 18:42

I am building an app that starts when a user takes a picture using their build-in Android camera, then taps the Share button, then chooses my app as the sharer, which is exp

相关标签:
2条回答
  • 2020-12-04 19:00

    I wanted to Share text content and i add the below code in manifest and its works...

        <activity android:name=".SendMessage.SendMessageLeads"
            android:label="SMS Composer"
            android:icon="@drawable/sms_composer">
    
            <intent-filter>
               <action android:name="android.intent.action.SEND" />
               <category android:name="android.intent.category.DEFAULT" />
               <data android:mimeType="text/plain" />
           </intent-filter>
    
        </activity>
    
    0 讨论(0)
  • 2020-12-04 19:02

    Functions like the "share via" in Android work with broadcast intents. The app creates this intent and the system reports all the activities that can execute that (twitter, fb...) You specify what an activity can do by means of intent filters.

    In your case I searched for "android camera share intent" and found generally that the intent filter looks like this:

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

    (not sure about the data section)

    I don't know if camera app uses a specific content provider, anyway your app should be able to manage at least the URI scheme that app uses.

    0 讨论(0)
提交回复
热议问题