I have an application which plays videos that I have on a multimedia server, recently I realized that in several devices it does not play for lack of internet access or so it shows, I have a method to verify the connection to the internet and if it does not have a Toast on the screen, the version I try and it does not work on is the 7.0, I've tried it on other devices and it works fine.
That way I have the permissions of the manifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
This is the WebView part
if (reachable) {
final Activity activity = this;
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.getLoadWithOverviewMode();
webView.loadUrl(urlvideo);
new cargarurl().execute();
} else {
Toast.makeText(this, getString(R.string.no_conection), Toast.LENGTH_LONG).show();
}
and with the following I check if you have an internet connection before displaying or uploading the url
public Boolean isOnlineNet() {
try {
Process p = Runtime.getRuntime().exec("ping -c 1 www.google.es");
int val = p.waitFor();
reachable = (val == 0);
return reachable;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}