List of usage examples for android.content Context getSystemService
@SuppressWarnings("unchecked") public final @Nullable <T> T getSystemService(@NonNull Class<T> serviceClass)
From source file:Main.java
public static Point getWindowSize(Context context) { Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point size = new Point(); display.getSize(size);//w w w . ja v a2s. co m return size; }
From source file:Main.java
public static Integer getScreenWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metrics); return metrics.widthPixels; }
From source file:Main.java
public static int getScreenWidth(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(outMetrics); int width = outMetrics.widthPixels; return width; }
From source file:Main.java
public static DisplayMetrics dueDisplayMetrics(Context context) { WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics dm = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(dm); return dm;/*from w ww . j a va2 s. c o m*/ }
From source file:Main.java
public static Integer getScreenHeight(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metrics); return metrics.heightPixels; }
From source file:Main.java
public static String getPhoneNumber(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String phoneNumberText = tm.getLine1Number(); return phoneNumberText; }
From source file:Main.java
public static String getAvailMemory(Context c) { ActivityManager am = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE); MemoryInfo mi = new MemoryInfo(); am.getMemoryInfo(mi);/*from www .j a v a2 s .co m*/ return Formatter.formatFileSize(c, mi.availMem); }
From source file:Main.java
public static int getDisplayWidth(Context context) { WindowManager wm = (WindowManager) (context.getSystemService(Context.WINDOW_SERVICE)); DisplayMetrics dm = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(dm); int mScreenWidth = dm.widthPixels; return mScreenWidth; }
From source file:Main.java
public static int getScreenHeight(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics outMetrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(outMetrics); int height = outMetrics.heightPixels; return height; }
From source file:Main.java
public static String getIMEI(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getSimSerialNumber(); }