Open Browser After Clicking Button - Android Studio

Button Click Function -

>> first you make a button on XML file or layout Design.
>> then Go to Activity Class and Define Button Property and Function.

public class MainActivity extends AppCompatActivity {
    private Button bt1;

    protected void onCreate(Bundle savedInstanceState) {

        bt1 = findViewById(;

        bt1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("enter your url"));

>> Yellow Highlighted Code is Show How to Open External link in browser, when Clicking a Button.

No comments:

Post a Comment