How to create photo sharing activity?

How to create a user activity that can be selected by the user through the share option when viewing the photo gallery? I have options like Share with Facebook, Twitter, FlickR, etc. But I want to add my own version there.

i.e. Go to "Photos", then click the "Share" button. You will be provided with many stock providers. What do I need to do to get my activity there?

+3
source share
2 answers

After looking at the built-in Mail app, I noticed this section in AndroidManifest.xml (thanks Janusz).

<intent-filter android:label="@string/app_name">
    <action android:name="android.intent.action.SEND" />
    <data android:mimeType="*/*" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

My application is now listed :)

+6
source

:

Intent shareImage = new Intent();
shareImage.setAction(Intent.ACTION_SEND);
String mimeTyp = "image/png";
shareImage.setType(mimeTyp);
shareImage.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(image));
startActivity(Intent.createChooser(shareImage, "Share Image"));

, Intent Filter , .

, , , :

<intent-filter ...>
   <action android:name="android.intent.action.SEND" />
   <data android:mimeType="image/png" android:scheme="http"... />
   .
   .
   .
</intent-filter>

, , .

+1

Source: https://habr.com/ru/post/1762536/


All Articles