is Android JDK - Android java.lang

Android examples for java.lang:System

Description

is Android JDK

Demo Code

import java.util.Enumeration;
import java.util.Properties;

public class Main {

  private static Boolean isAndroid;

  public static boolean isAndroid() {
    if (isAndroid == null) {
      try {//ww w.j  av  a2 s  . c o  m
        isAndroid = System.getProperties().get("java.vendor").toString().toLowerCase().contains("android");
        if (isAndroid) {
          return isAndroid;
        }
      } catch (Exception e) {
      }
      try {
        isAndroid = System.getProperties().get("java.vm.vendor").toString().toLowerCase().contains("android");
        if (isAndroid) {
          return isAndroid;
        }
      } catch (Exception e1) {
        try {
          isAndroid = System.getProperties().get("java.vm.name").toString().toLowerCase().equals("dalvik");
        } catch (Exception e2) {
          try {
            Properties p = System.getProperties();
            Enumeration keys = p.keys();
            while (keys.hasMoreElements()) {
              String key = (String) keys.nextElement();
              String value = (String) p.get(key);
              System.out.println("  > " + key + "=" + value);
              if (value.toLowerCase().contains("android")) {
                isAndroid = true;
                return isAndroid;
              }
            }
          } catch (Exception e3) {
            isAndroid = false;
          }
        }
      }
    }
    return isAndroid;
  }

}

Related Tutorials