Open Website from App in external Web Browser

Creates an intent that opens a website in Android's Web Browser (external).


Libraries

Code Snippet
void OpenWebsite(String url) {
    if (!url.startsWith("http://") && !url.startsWith("https://"))
        url = "http://" + url;
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    startActivity(browserIntent);
}


Implementation

Use the method above to open the webiste. Example:<code>OpenWebsite("google.com");</code> This should open the URL <code>http://google.com</code>





Comments
  • mode_editWrite a comment



  • forumComments




Embed Code

We provide special containers which include the full snippet and a link to this site. So for example when you make a tutorial and you are using code from this site, you can use one of the following snippet embeddings:

Load Preview Get Code Close Preview







    Share
    Rating
    thumb_up 1 thumb_down
    Author
    Thorolus

    I'm the head developer and co-founder of GlovilGames Studios (glovilgames.com) and other platforms GlovilGames created, like vsnippets.com, worth-calculator.net, python-obfuscator.com and some mobile apps and games.

    Tags
    Android
    Website
    Intent
    Activity



    Informations

    posted on 2016-09-14 19:58:46

    viewed 136 times

    snippet's UUID is 57d98fd67f643

    Similar Snippets