• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

go to url link with a button

i have on AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

and on MainActivity

MaterialButton button1 = (MaterialButton) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View v) {
Uri uri = Uri.parse("https://www.paypal.com/donate/?hosted_button_id=DSHESVB635SNJ");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});

on activity_main.xml

<com.google.android.material.button.MaterialButton
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:text="Donate"

when i test the app and click on the button it doesn't do anything

i want it to go visit the link when the button is clicked
 
This code works

link.png
 
Back
Top Bottom