Do this using the intent filter with the SEND action. This filter will accept simple texts, images and videos.
<activity android:name="MyActivity"> <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> <data android:mimeType="image/*" /> <data android:mimeType="video/*" /> </intent-filter> </activity>
In your activity, you can check getIntent().getAction().equals(Intent.ACTION_SEND) to know that you were running as a send action, and getIntent().getType() , what type of data you received.
The data itself (text, image or anything else) can be found through getIntent().getExtras().get(Intent.EXTRA_STREAM) or getIntent().getStringExtra(Intent.EXTRA_TEXT) (depends on the type of data and the sending application).
H9kDroid
source share