I want to redirect user to particular URL while clicking on Button
in Android App.
You can wrap the buttons in anchors that href to the appropriate website. When the user clicks the button (input) they are directed to the destination specified in the href property of the anchor.
Add a new URL redirectClick the URL Redirects tab. In the upper right, click Add URL redirect. In the right panel, select the Standard or Flexible redirect type. A standard redirect is used to redirect one URL to another.
You can start a 'view' activity, which would be the browser given a URL:
public class HelloWorld extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Assuming you are using xml layout
Button button = (Button)findViewById(R.id.Button01);
button.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent viewIntent =
new Intent("android.intent.action.VIEW",
Uri.parse("http://www.stackoverflow.com/"));
startActivity(viewIntent);
}
});
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With