Registering for Android Intents – Being a crappy browser

One of the most powerful concepts of Android Development is that you can send asynchronously messages to other activities and services via Intents. The standard case is that you specify the intent you want to call and then Android starts the corresponding activity.

You can also register yourself to existing events. For example if you writing an browser application you can register yourself in “” via the following intent filter as a browser.

  <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".BrowserActivitiy"
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="http"/> 


If you install this application and open an URL in another application you should get a popup asking which application should be opened. As now two application have registered for the same intent the user have to choose which one should be used.

Once your activity is called you can use getIntent() to access the intent. The method getActivity() provides you the action and getData() let you access the data which was pasted. In this example we will simply read the HTML data and load it into a text view.

For more information please see Android Intents and Android Networking.

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Android, Eclipse and tagged , . Bookmark the permalink.