Example usage for android.content.pm PackageInfo getClass

List of usage examples for android.content.pm PackageInfo getClass

Introduction

In this page you can find the example usage for android.content.pm PackageInfo getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:Main.java

public static int getMoveType(PackageInfo pInfo, ApplicationInfo info) {
    int moveType = MOVEAPPTYPE_NONE;
    if ((FLAG_EXTERNAL_STORAGE & info.flags) != 0) {
        moveType = MOVEAPPTYPE_MOVETOPHONE;
    } else if (pInfo != null) {
        int installLocation = 1;
        try {//w w w  .j  a va2s . c o m
            Field field = pInfo.getClass().getDeclaredField("installLocation");
            field.setAccessible(true);
            installLocation = field.getInt(pInfo);
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        if (installLocation == 0) {
            moveType = MOVEAPPTYPE_MOVETOSDCARD;
        } else if (installLocation == -1 || installLocation == 1) {
            moveType = MOVEAPPTYPE_NONE;
        }
    }
    return moveType;
}

From source file:Main.java

public static int getMoveType(PackageInfo pInfo, ApplicationInfo info) {
    int moveType = MOVEAPPTYPE_NONE;
    if ((FLAG_EXTERNAL_STORAGE & info.flags) != 0) {
        moveType = MOVEAPPTYPE_MOVETOPHONE;
    } else if (pInfo != null) {
        int installLocation = 1;
        try {//from   w ww  .  j a va2 s  .  co m
            Field field = pInfo.getClass().getDeclaredField("installLocation");
            field.setAccessible(true);
            installLocation = field.getInt(pInfo);
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        if (installLocation == 0) {
            moveType = MOVEAPPTYPE_MOVETOSDCARD;
        } else if (installLocation == -1 || installLocation == 1) {
            moveType = MOVEAPPTYPE_NONE;
        }
    }
    System.out.println("moveType..............." + moveType);
    return moveType;
}