3

I added the intent-filter to ApplicationManifest.xml to take my app to "Share via" Dialog:

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

How can I handle the request from another app.

1 Is it possible to differentiate between directly app-start and sharing start?

2 How to get access to sharing data?

Mark
  • 17,887
  • 13
  • 66
  • 93
  • 1
    http://stackoverflow.com/questions/4182299/how-to-get-the-data-from-share-picture-via-dialog-on-android – bigstones Feb 22 '11 at 14:17

2 Answers2

4

In onCreate you can call getIntent() to see if there is any data in the bundle. Use the getData() method to retrieve a Uri or one of the get...Extra methods to retrieve any other expected data.

void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.id.main);
    ...
    Intent i = getIntent();
    Uri data = i.getUri(); 
    if(data != null) {
    // do something interesting
    }
    /* or */
    String text = i.getStringExtra(Intent.EXTRA_TEXT);
    / * do something interesting with the text */
}
Robby Pond
  • 73,164
  • 16
  • 126
  • 119
0

regarding question 1: in direct app-start case, the intent action would not be SEND.

for question 2 see my comment.

bigstones
  • 15,087
  • 7
  • 65
  • 82