Android: How to open a webpage

There's more than one way to skin a cat here. It really depends on exactly what you want to do.

First of all, you'll need to give your app the right privileges for using the internet and add "android.permission.INTERNET" to the permissions.

Clickable links in a text-view using Layout

This is the easiest way of doing it without coding.

  • While editing your XML layout, click on the view you wish to apply auto-links to.
  • In the Properties dialog, edit "Auto links" and set it to all that apply to you.
  • Set "Links clickable" to true.
  • Whalla!

Clickable links in a text-view via code

If you prefer the more code-saavy way of doing it, then use this snippet to make your links clickable.

TextView tv = (TextView) findViewById(; Linkify.addLinks(tv, Linkify.WEB_URLS);

Display HTML in a view

Manually fetching or setting HTML into a view is quite easy.

Or you could tell the view to load the remote page for you.

WebView wv = (WebView)findViewById(;

Open up the built-in browser

Lastly, just let the pro's handle it. Send off your request to the default web browser on your Android handset.

Uri uri = Uri.parse("");
startActivity(new Intent(Intent.ACTION_VIEW, uri));

[ Source ]

Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog