Does not access the Internet from WebView on some devices

1

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;
}
    
asked by Leonardo Henao 27.07.2017 в 00:21
source

1 answer

2

I had commented, here that what you are trying to do is wrong, check my answer:

How to detect when there is internet available on Android?

Add permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

and use this method:

private static ConnectivityManager manager;

public static boolean isOnline(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    return networkInfo != null && networkInfo.isAvailable() && networkInfo.isConnected();
}

When a video is not loaded within a WebView , the causes are usually:

  • There is no internet connection.
  • Video codec not supported.
  • The browser contains javascript objects that are not supported. Remember that a WebView on Android is a limited browser.

In this case when analyzing your video,

link

this has a Mime Type not supported by android devices for video playback:

  

VideoCapabilities: Unsupported mime video / sorenson

    
answered by 27.07.2017 / 03:00
source