Open Url using Installed App in Android Studio  

In this article we will learn how to open Url from our application to installed application like crome,safari etc.we are using Android Studio to build our application and language on codebehind.

0 340 Technology | Android App
Sat Nov 10 , 2018

Step 1 : Create a new project name it - OpenUrlExample

Step 2 : Select Empty Activity

Step 3 : Open main_activity.xml

Copy and paste code


<Button
        android:id="@+id/btn_visitdefault"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="12dp"
        android:text="Visit Our Default Page Google"/>

Step 4 : Now Open MainActivity.java

Copy and paste code


    Button defaultview;
    
    Intent intent;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_step_two);

        
        defaultview=findViewById(R.id.btn_visitdefault);
        

        
        defaultview.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String visitweb="https://www.google.com/";
                intent=new Intent(Intent.ACTION_VIEW, Uri.parse(visitweb));
                startActivity(intent);
            }
        });

        
    }

Build the project

Run


Subscribe & Get Regular Updates On Your E-mail