List of usage examples for android.content Context getApplicationContext
public abstract Context getApplicationContext();
From source file:Main.java
public static SharedPreferences.Editor getDefaultPrefsEditor(Context ctx) { return PreferenceManager.getDefaultSharedPreferences(ctx.getApplicationContext()).edit(); }
From source file:Main.java
public static SharedPreferences getPrefManager(Context ctx) { return PreferenceManager.getDefaultSharedPreferences(ctx.getApplicationContext()); }
From source file:Main.java
public static float getFloat(Context context, String key, float defValue) { SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); return sp.getFloat(key, defValue); }
From source file:Main.java
public static boolean checkSensor(int sensor, Context context) { SensorManager sensorManger = (SensorManager) context.getApplicationContext() .getSystemService(Context.SENSOR_SERVICE); List<Sensor> lista = sensorManger.getSensorList(sensor); return lista.size() > 0; }
From source file:Main.java
public static String getString(Context context, String key, String defValue) { SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); return sp.getString(key, defValue); }
From source file:Main.java
public static float getDeviceScaledDensity(Context cx) { DisplayMetrics dm = new DisplayMetrics(); dm = cx.getApplicationContext().getResources().getDisplayMetrics(); return dm.scaledDensity; }
From source file:Main.java
public static float getDeviceWidth(Context cx) { DisplayMetrics dm = new DisplayMetrics(); dm = cx.getApplicationContext().getResources().getDisplayMetrics(); return dm.widthPixels; }
From source file:Main.java
public static String getModelPath(String modelName, Context mContext) { String path = null;//from w w w. j a v a 2s . c o m File dataDir = mContext.getApplicationContext().getExternalFilesDir(null); if (dataDir != null) { path = dataDir.getAbsolutePath() + File.separator + modelName; } return path; }
From source file:Main.java
public static boolean hasInternet(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); return info != null && info.isAvailable() && info.isConnected(); }
From source file:Main.java
public static boolean getBoolean(Context context, String key, boolean defValue) { SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); return sp.getBoolean(key, defValue); }