How to open a website when a Button is clicked in Android application?

前端 未结 10 2079
囚心锁ツ
囚心锁ツ 2020-12-01 00:23

I am designing an app, with several button for users to click on. Once button is clicked, user is directed to appropriate website. How do I accomplish this?

10条回答
  •  半阙折子戏
    2020-12-01 01:13

    you can use this on your button click activity

    Intent webOpen = new Intent(android.content.Intent.ACTION_VIEW);
                WebOpen.setData(Uri.parse("http://www.google.com"));
                    startActivity(myWebLink);
    

    and import this on your code

    import android.net.Uri;
    

提交回复
热议问题