List of utility methods to do Context Get
int | getIntSPR(String key, Context context) get Int SPR SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(context);
return preferences.getInt(key, 0);
|
Location | getLastKnownLocation(Context context) get Last Known Location LocationManager lm = (LocationManager) context .getSystemService(Context.LOCATION_SERVICE); List<String> providers = lm.getProviders(true); SharedPreferences settings = PreferenceManager .getDefaultSharedPreferences(context); SharedPreferences.Editor settingsEditor = settings.edit(); Location loc = null; for (int i = providers.size() - 1; i >= 0; i--) { ... |
Paint | getLineErrorPaint(Context context) get Line Error Paint final float lineThicknessPx = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, DEFAULT_LINE_THICKNESS, context.getResources().getDisplayMetrics()); final Paint borderPaint = new Paint(); borderPaint.setColor(DEFAULT_LINE_ERROR_COLOR); borderPaint.setStrokeWidth(lineThicknessPx); borderPaint.setStyle(Paint.Style.STROKE); borderPaint.setAntiAlias(true); ... |
Paint | getLinePaint(Context context) get Line Paint final float lineThicknessPx = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, DEFAULT_LINE_THICKNESS, context.getResources().getDisplayMetrics()); final Paint borderPaint = new Paint(); borderPaint.setColor(DEFAULT_LINE_COLOR); borderPaint.setStrokeWidth(lineThicknessPx); borderPaint.setStyle(Paint.Style.STROKE); borderPaint.setAntiAlias(true); ... |
float | getLineThickness(Context context) get Line Thickness return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
DEFAULT_LINE_THICKNESS, context.getResources()
.getDisplayMetrics());
|
LocationProvider | getLocationProvider(Context context) get Location Provider if (context != null) { LocationProvider networkProvider = null; LocationProvider gpsProvider = null; LocationManager lm = (LocationManager) context .getSystemService(Context.LOCATION_SERVICE); if (lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { networkProvider = lm .getProvider(LocationManager.NETWORK_PROVIDER); ... |
Long | getLongSPR(String key, Context context) get Long SPR SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(context);
return preferences.getLong(key, Long.MAX_VALUE);
|
int | getMemoryClass(Context context) get Memory Class return ((ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE))
.getMemoryClass();
|
int | getMinFontSize(Context context) get Min Font Size retrieveDisplayMetrics(context); float sys_scale = context.getResources().getConfiguration().fontScale; return (int) (MIN_FONT_SIZE * _display_metrics.density * STANDARD_DPI * sys_scale); |
PackageInfo | getMobilityPackageInfo(Context context) Returns the mobility package info if mobiliy and accelservice exist try { PackageManager pm = context.getPackageManager(); return pm.getPackageInfo("org.ohmage.mobility", 0); } catch (PackageManager.NameNotFoundException e) { return null; |