Android - Browser URL Sharing

I am writing a community application that has the ability to share URLs.

The Android browser has the ability to forward URLs, for example, from my HTC Desire to BlueTooth Target, to Facebook, to Friend Stream, to Google Mail, to Google+, Mail, SMS and Peep. What I want to achieve is to add my application to this list, providing the functionality to forward the current URL from the browser to the application, no matter what webpage I am on.

How to do it?

+8
android
source share
1 answer

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).

+14
source share

All Articles