0

I guess the question is the description. Plain, simple... How can I do this in a simple and easy way? I have done this before in regular Java, but android being so similar and yet soooo different seems to have a different way of doing so.

-Thanks!

CodeMonkeyAlx
  • 813
  • 4
  • 16
  • 32
  • I don't honestly see why it should be so similar: Android is a completely different platform than a desktop.. – Kristopher Micinski Dec 04 '12 at 22:23
  • 1
    Duplicate: http://stackoverflow.com/questions/3004515/android-sending-an-intent-to-browser-to-open-specific-url But Ahmad's answer is correct. – Terel Dec 04 '12 at 22:23

1 Answers1

3

You can do it with this in your OnCreate() method:

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

Or if you don't want to open it in a web browser you can load it in a WebView like this:

WebView myWebView  = (WebView) findViewById(R.id.yourWebView);
myWebView.loadUrl("yourLink");
myWebView.setWebViewClient(new MyWebViewClient());

but then don't forget to create a WebViewClient:

public class MyWebViewClient extends WebViewClient {

     @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
}
Ahmad
  • 69,608
  • 17
  • 111
  • 137