tags:

views:

61

answers:

2

hi,i want to redirect to particular URL while clicking on button

+3  A: 

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);
      }
    });

  }

}
Maxwell Troy Milton King
Thank you very much it's working
deepthi
A: 

very nice, there is a way to send a URL but without showing the response in a navigator, o receive the response ina string so you can analizite. thank you

htcdroid
If the intent is set to 'android.intent.action.VIEW' and a URI scheme of http:, il will launch the web browser. If the scheme is mailto:, it will launch the mail client ...http://developer.android.com/intl/fr/reference/android/content/Intent.html#ACTION_VIEW
ccheneson