open a url on click of ok button in android

前端 未结 6 402
情深已故
情深已故 2020-12-12 17:15

I have to open a URL on Click of OK Button in a view. Can someone tell how to do this?

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 17:43

    You can use the below method, which will take your target URL as the only input (Don't forget http://)

    void GoToURL(String url){
        Uri uri = Uri.parse(url);
        Intent intent= new Intent(Intent.ACTION_VIEW,uri);
        startActivity(intent);
    }
    

提交回复
热议问题