Android Utililty Methods Context Get

List of utility methods to do Context Get

Description

The list of methods to do Context Get are organized into topic(s).

Method

intgetMobilityVersion(Context context)
Returns the version of mobility if it exists, -1 otherwise
PackageInfo info = getMobilityPackageInfo(context);
if (info != null)
    return info.versionCode;
return -1;
ContextgetMusesAppContext()
get Muses App Context
return sContext;
StringgetNameFromUri(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
...
floatgetOffset(Context context)
get Offset
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
        DEFAULT_OFFSET, context.getResources().getDisplayMetrics());
intgetOpenGLESVersion(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;
...
intgetOrientation(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);
StringgetPackageName(final Context context)
Get the application package name.
return context.getPackageName();
StringgetPackageVersion(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) + ".";
...
intgetPackageVersionAsInt(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");
...
StringgetPath(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()) {
...