How to open an URL in Android’s web browser

Here’s a code snippet to show you how to use “android.content.Intent” to open an specify URL in Android’s web browser.


	button.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View arg0) {

			Intent intent = new Intent(Intent.ACTION_VIEW, 
			     Uri.parse("http://www.mkyong.com"));
			startActivity(intent);

		}

	});
Note
For full example, please refer to this – Android button example.

References

  1. Android Button JavaDoc
  2. Android Intent.ACTION_VIEW JavaDoc

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
8 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
7 Comment authors
SriRamAmanTharindu Irashanafatimaavon Recent comment authors
newest oldest most voted
fatima
Guest
fatima

it was a great help thankyou !

SriRam
Guest
SriRam

i want to call a url – nothing to be displayed or nothing to be get as a rsponce but i want to call that – can you help me with any snippet

trackback
Android Followers » Android Tutorial From mkyong.com

[…] How to open an URL in Android’s web browser […]

Gowtham Raj
Guest
Gowtham Raj

easy to understand

haris
Guest
haris

How to create a browser with block of all unwanted url’s in android??

avon
Guest
avon

thank you !!!!

Tharindu Irashana
Guest
Tharindu Irashana

thank you sir

Aman
Guest
Aman

this will open the browser, but how to open the link in background