开发者

how to redirect to particular URL while clicking on button in android?

开发者 https://www.devze.com 2022-12-20 05:16 出处:网络
I want to redirect user t开发者_运维百科o particular URL while clicking on Button in Android App.You can start a \'view\' activity, which would be the browser given a URL:

I want to redirect user t开发者_运维百科o particular URL while clicking on Button in Android App.


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

  }

}
0

精彩评论

暂无评论...
验证码 换一张
取 消