determine If WebView Available - Android android.webkit

Android examples for android.webkit:WebView

Description

determine If WebView Available

Demo Code

import android.content.Context;
import android.content.pm.PackageManager;

public class Main {

  private static boolean sWebViewUnavailable;


  public static void determineIfWebViewAvailable(Context context, Throwable t) {
    sWebViewUnavailable = !hasWebViewFeature(context) && checkCauseWasUnsupportedOperation(t);
  }//  w w  w  .j av  a 2 s  . c  o m

  private static boolean hasWebViewFeature(Context context) {

    PackageManager pm = context.getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_WEBVIEW);
  }

  private static boolean checkCauseWasUnsupportedOperation(Throwable t) {
    if (t == null)
      return false;
    while (t.getCause() != null) {
      t = t.getCause();
    }
    return t instanceof UnsupportedOperationException;
  }

}

Related Tutorials