Android Context Get getMobilityVersion(Context context)

Here you can find the source of getMobilityVersion(Context context)

Description

Returns the version of mobility if it exists, -1 otherwise

Parameter

Parameter Description
context a parameter

Declaration

public static int getMobilityVersion(Context context) 

Method Source Code

//package com.java2s;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

public class Main {
    /**/* www  .  j  av a  2s  .  co m*/
     * Returns the version of mobility if it exists, -1 otherwise
     * 
     * @param context
     * @return
     */
    public static int getMobilityVersion(Context context) {
        PackageInfo info = getMobilityPackageInfo(context);
        if (info != null)
            return info.versionCode;
        return -1;
    }

    /**
     * Returns the mobility package info if mobiliy and accelservice exist
     * 
     * @param context
     * @return the mobility package info
     */
    private static PackageInfo getMobilityPackageInfo(Context context) {
        try {
            PackageManager pm = context.getPackageManager();
            return pm.getPackageInfo("org.ohmage.mobility", 0);
        } catch (PackageManager.NameNotFoundException e) {
            // Don't do anything
        }
        return null;
    }
}

Related

  1. getLocationProvider(Context context)
  2. getLongSPR(String key, Context context)
  3. getMemoryClass(Context context)
  4. getMinFontSize(Context context)
  5. getMobilityPackageInfo(Context context)
  6. getMusesAppContext()
  7. getNameFromUri(Context context, Uri uri)
  8. getOffset(Context context)
  9. getOpenGLESVersion(final Context context)