List of utility methods to do Context Get
int | getMobilityVersion(Context context) Returns the version of mobility if it exists, -1 otherwise PackageInfo info = getMobilityPackageInfo(context); if (info != null) return info.versionCode; return -1; |
Context | getMusesAppContext() get Muses App Context return sContext;
|
String | getNameFromUri(Context context, Uri uri) get Name From Uri if (uri.getScheme().equals("file")) { return new File(uri.getPath()).getName(); } else if (uri.getScheme().equals("content")) { Cursor cursor = context.getContentResolver().query(uri, null, null, null, null, null); try { if (cursor != null && cursor.moveToFirst()) { return cursor.getString(cursor ... |
float | getOffset(Context context) get Offset return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
DEFAULT_OFFSET, context.getResources().getDisplayMetrics());
|
int | getOpenGLESVersion(final Context context) This method returns the version code of OpenGL ES on the system. final PackageManager packageManager = context.getPackageManager(); final FeatureInfo[] featureInfos = packageManager .getSystemAvailableFeatures(); if (featureInfos != null && featureInfos.length > 0) { for (FeatureInfo featureInfo : featureInfos) { if (featureInfo.name == null) { if (featureInfo.reqGlEsVersion != FeatureInfo.GL_ES_VERSION_UNDEFINED) { return (featureInfo.reqGlEsVersion & 0xffff0000) >> 16; ... |
int | getOrientation(Context context, Uri photoUri) get Orientation Cursor cursor = context .getContentResolver() .query(photoUri, new String[] { MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null); if (cursor.getCount() != 1) { return -1; cursor.moveToFirst(); return cursor.getInt(0); |
String | getPackageName(final Context context) Get the application package name. return context.getPackageName();
|
String | getPackageVersion(Context c) get Package Version String packageVersion = ""; try { PackageInfo pInfo = c.getPackageManager().getPackageInfo( c.getPackageName(), 0); packageVersion += "I have OpenWatch version " + pInfo.versionName; packageVersion += " running on Android API " + String.valueOf(Build.VERSION.SDK_INT) + "."; ... |
int | getPackageVersionAsInt(Context c) get Package Version As Int int packageVersion = 0; try { PackageInfo pInfo = c.getPackageManager().getPackageInfo( c.getPackageName(), 0); packageVersion = pInfo.versionCode; } catch (PackageManager.NameNotFoundException e) { Log.e("getPackageVersion", "Unable to read PackageName in RegisterApp"); ... |
String | getPath(Context context, Uri uri) get Path if ("content".equalsIgnoreCase(uri.getScheme())) { String[] projection = { "_data" }; Cursor cursor = null; try { cursor = context.getContentResolver().query(uri, projection, null, null, null); int column_index = cursor.getColumnIndexOrThrow("_data"); if (cursor.moveToFirst()) { ... |