How to create an application that I can "share" the URL on Android?

Please can someone explain in Plain English how I create an application that Android can offer as a goal if I β€œshare” the URL from the device’s browser?

I find the official Google documentation for the SDK almost impenetrable and (for now) devoid of any real-world examples of passing URLs from a browser to another application. : - (

I would be very grateful for any advice that people could offer; It feels as if I slammed my head on a large green brick wall right now.

Thanks in advance!

+4
source share
2 answers

You want to create an application that can handle ACTION_SEND and then register the intent filter in your AndroidManifest.xml file. I copied the following example from the default Mms application for Android manifest :

 <activity android:name=".ui.ComposeMessageActivity" android:configChanges="orientation|keyboardHidden" android:windowSoftInputMode="stateHidden" android:launchMode="singleTop" > <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter> <!-- ... --> </activity> 
+1
source

It was necessary to execute it in a simple way in my application and solve the following:

 String strUrl = "http://example.com"; Intent shareUrl = new Intent(Intent.ACTION_SEND); shareUrl.setType("text/plain"); shareUrl.putExtra(android.content.Intent.EXTRA_TEXT, strUrl); startActivity(Intent.createChooser(shareURL,"Share with...")); 

This is the easiest way to share your content with other applications on your device. Practical and functional.

-1
source

All Articles