List of usage examples for android.content Context getApplicationContext
public abstract Context getApplicationContext();
From source file:Main.java
public static void toastMsg(String msg, Context con) { Toast toast = Toast.makeText(con.getApplicationContext(), msg, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP, 0, 80); toast.show();//from w ww . j a v a 2s. c o m }
From source file:Main.java
public static int spToPx(Context context, int spValue) { float scale = context.getApplicationContext().getResources().getDisplayMetrics().scaledDensity; return (int) (spValue * scale + 0.5f); }
From source file:Main.java
public static float getScreenDensity(Context context) { DisplayMetrics metrics = context.getApplicationContext().getResources().getDisplayMetrics(); return metrics.density; }
From source file:Main.java
public static int initScreenWidth(Context context) { DisplayMetrics curMetrics = context.getApplicationContext().getResources().getDisplayMetrics(); return curMetrics.widthPixels; }
From source file:Main.java
public static void clear(Context context) { SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); Editor editor = sp.edit();//from w ww . j a va 2 s .c om editor.clear(); editor.commit(); }
From source file:Main.java
public static void showToast(Context context, String message) { Toast.makeText(context.getApplicationContext(), message, Toast.LENGTH_LONG).show(); }
From source file:Main.java
public static File createDefaultCacheDir(Context context) { File cache = new File(context.getApplicationContext().getCacheDir(), PICASSO_CACHE); if (!cache.exists()) { cache.mkdirs();/* w ww . j a va2 s .c om*/ } return cache; }
From source file:Main.java
static File createApiCacheDir(Context context) { File cache = new File(context.getApplicationContext().getCacheDir(), API_CACHE); if (!cache.exists()) { cache.mkdirs();/*from w w w .j av a 2 s . co m*/ } return cache; }
From source file:Main.java
public static void setActivityHandler(Context context) { mApplicationContextHandler = context.getApplicationContext(); }
From source file:Main.java
public static int px2dip(Context context, float pxValue) { final float scale = context.getApplicationContext().getResources().getDisplayMetrics().density; return (int) (pxValue / scale + 0.5f); }