How to open an URL in Android’s web browser

Here’s a code snippet to show you how to use “android.content.Intent” to open an specify URL in Android’s web browser. button.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://mkyong.com")); startActivity(intent); } }); Note For full example, please refer to this – Android button example. References Android Button JavaDoc Android …

Read more

Open Browser in Java windows or Linux

A very useful Java code, to open a web browser from Java application in windows or Linux. package com.mkyong; public class StartBrowser { public static void main(String args[]) { String url = "http://www.google.com"; String os = System.getProperty("os.name").toLowerCase(); Runtime rt = Runtime.getRuntime(); try{ if (os.indexOf( "win" ) >= 0) { // this doesn’t support showing urls …

Read more