Android tutorial: launch website (Http) from Android application

In this small tutorial I show you how you can launch a website from an Android application. We use a button to initiate the launch of a website and an Intent with Uri parse.

package com.example.launchwebsite;

import android.os.Bundle;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

String url1 = "";

    public void onCreate(Bundle savedInstanceState) {
        Button btnlaunchwebsite = (Button)findViewById(;
        btnlaunchwebsite.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent i = new Intent(Intent.ACTION_VIEW);


- Create a variable for the website you want to launch (in my case String url1 = “” ).
- Create your button reference via findViewById.
- Set a OnClickListener to your Button.
- Create an Intent with ACTION_VIEW.
- Parse the Url1 variable with Uri.Parse.
- Finally, don’t forget to call startActivity.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>