HelloCW
HelloCW

Reputation: 2235

How to share images in android?

I have installed Dropbox, Gmail plus in my android. I have read the article Launch Dropbox from my app Android.

I hope to share my images to Dropbox or Gmail plus , I think the following code will popup a menu let me select Dropbox ,Gmail plus or othe App to share my images, but I get a prompt infomation: No applications can perform the action. Why?

Intent intent = new Intent(Intent.ACTION_SEND);
startActivity(Intent.createChooser(intent, "title");

Upvotes: 0

Views: 103

Answers (2)

Robert Rowntree
Robert Rowntree

Reputation: 6289

2 changes recommended to implement share in your picture app :

In the manifest, add this to the filter for the action you want to include in the menu that will drop-down when the user taps the standard share icon from the standard action bar:

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

In your OnCreate/OnResume for the activity which contains the manifest filter above... handle the SEND :

   if (Intent.ACTION_SEND.equals(
       getIntent().getAction()) && getIntent().getType() != null) {
       ...
    }

Upvotes: 2

TN888
TN888

Reputation: 7739

Because you have to use intent.putExtra ()

Please read the following article

Upvotes: 2

Related Questions