예제 #1
0
 public static int dp2px(int dip) {
   Context context = KissTools.getApplicationContext();
   Resources resources = context.getResources();
   int px =
       Math.round(
           TypedValue.applyDimension(
               TypedValue.COMPLEX_UNIT_DIP, dip, resources.getDisplayMetrics()));
   return px;
 }
예제 #2
0
  public static final String getAndroidId() {
    Context context = KissTools.getApplicationContext();
    String androidID = null;
    try {
      androidID = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
    } catch (Exception e) {

    }
    return androidID;
  }
예제 #3
0
  public static final String getWlanMac() {
    Context context = KissTools.getApplicationContext();
    String wlanMac = null;
    try {
      WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
      wlanMac = wm.getConnectionInfo().getMacAddress();
    } catch (Exception e) {

    }
    return wlanMac;
  }
예제 #4
0
  public static final String getIMEI() {
    Context context = KissTools.getApplicationContext();
    String deviceIMEI = null;
    try {
      TelephonyManager teleManager =
          (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
      deviceIMEI = teleManager.getDeviceId();
    } catch (Exception e) {

    }
    return deviceIMEI;
  }
예제 #5
0
 public static float getScreenInches() {
   Context context = KissTools.getApplicationContext();
   float screenInches = -1;
   try {
     Resources resources = context.getResources();
     DisplayMetrics dm = resources.getDisplayMetrics();
     double width = Math.pow(dm.widthPixels / dm.xdpi, 2);
     double height = Math.pow(dm.heightPixels / dm.ydpi, 2);
     screenInches = (float) (Math.sqrt(width + height));
   } catch (Exception e) {
   }
   return screenInches;
 }
예제 #6
0
 public static int sp2px(float sp) {
   Context context = KissTools.getApplicationContext();
   final float scale = context.getResources().getDisplayMetrics().scaledDensity;
   int px = Math.round(sp * scale);
   return px;
 }
예제 #7
0
 public static int px2dp(int px) {
   Context context = KissTools.getApplicationContext();
   DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
   int dp = Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
   return dp;
 }