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();
}
}
.png)
0 comentarios: