Android add my app to “Share” button in gallery

后端 未结 2 2007
走了就别回头了
走了就别回头了 2021-02-05 22:28

I succeed to add my app in the \"share\" button in the Android gallery, so if I click on it, my app will start. Can I choose which activity of my app to start? Now it starts th

相关标签:
2条回答
  • 2021-02-05 23:05

    If you had two activities in your manifest file, say Main and MediaShare then it would look something like this:

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

    The android.intent.action.SEND action and android:mimeType="image/*" data should go with the activity you want to start when you share an image.

    See the page on Receiving Content from Other Apps for more details.

    0 讨论(0)
  • 2021-02-05 23:08

    Put your intent filter under activity you want to start into your manifest

     <activity android:name=".Theme"
               android:label="MAIN">
       <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
       </intent-filter>
    </activity>
    
     <activity android:name=".Theme"
               android:label="ActiVITY2">
      <intent-filter>
       <action android:name="android.intent.action.SEND" />
       <category android:name="android.intent.category.DEFAULT" />
       <data android:mimeType="image/*" />
      </intent-filter>
    </activity>
    
    0 讨论(0)
提交回复
热议问题