I am writing an app for a community, which has the ability to share URLs.
In the android browser, there is the possibility to forward URLs, for example from my HTC Desire to a BlueTooth Target, to Facebook, to Friend Stream, to Google Mail, to Google+, Mail, SMS and Peep. What I want to achive is to add my app into that list, providing functionality to forward the current URL from the Browser to the App, regardless on which webpage I am currently.
How do I achive that?
You do this with intent-filter, with the action SEND. This filter will take plain 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 you have been started as a send action and
getIntent().getType() what type of data you got.
The data itself (Text, image or anything else) can be found via
getIntent().getStringExtra(Intent.EXTRA_TEXT) (Depends on data type and the sending application).