Introduction
In the last article How to Open New Activity on Click Button by Existing Activity In Android, we saw how to communicate with a new activity. You know the intent is divided into the three parts Action, Data and Category. In general, an Action is something to be performed, such as the action view, action edit and action main. And Data is something to be operated on, such as a personal record, contact database, or Uri.
Today I will explain how to use an Intent in an online application in Android.
Step 1
Create a new project using "File" -> "New" -> "Android Application Project" and name it "IntentExample" as shown below.

Step 2
Open "activity_main.xml" as "IntentExample/res/layout/activity_main.xml" and update it as in the following:
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context="com.intent.example.MainActivity"
- android:layout_gravity="center">
- <Button
- android:id="@+id/btn"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="openBrowser"
- android:text="@string/browser_btn" >
- </Button>
- </RelativeLayout>
Step 3
Open "string.xml" as "IntentExample/res/values/string.xml" and update it as shown in the following:
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <string name="app_name">IntentExample</string>
- <string name="hello_world">Hello world!</string>
- <string name="menu_settings">Settings</string>
- <string name="browser_btn">Open</string>
- </resources>
Step 4
Open "MainActivity.java" as "IntentExample/src/com.intent.example" and update it with your logic; whatever you want to do.



Gowtham RajamanickamPosted Apr 12, 2016, 2:08 AM
Good One, Thanks for sharing
Amir AliPosted May 30, 2013, 4:02 AM
what type of intent is this implicit or explicit