Cómo abrir una página web desde una aplicación Android

Función para lanzar el navegador externo con una url especifica desde nuestra aplicación en Android

/**
* Para lanzar el navegador web
* @param string url  dirección web
*/
public void openWebURL(String url ) {
   if (!URLUtil.isValidUrl(url)) {
       if (!url.startsWith("http://") && !url.startsWith("https://"))
           url = "http://" + url;

   }
   try {
       Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
       startActivity(myIntent);
   } catch (ActivityNotFoundException e) {
       Toast.makeText(this, "No application can handle this request."
               + " Please install a webbrowser",  Toast.LENGTH_LONG).show();
       e.printStackTrace();
   }
}

webserveis

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard.

0 comentarios: