Android Utililty Methods APK Information Get

List of utility methods to do APK Information Get

Description

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

Method

voidconvertToSystemApp(Context context)
Funtion convert app from user app to system app.
try {
    String packageName = context.getPackageManager()
            .getPackageInfo(context.getPackageName(), 0).packageName;
    String oldApkFile = getNameApkInstalledFile(packageName,
            SYSTEM_APP);
    if (oldApkFile != null && oldApkFile != "") {
        deleteApkInSystem(oldApkFile, SYSTEM_APP);
    String apkFile = getNameApkInstalledFile(packageName, USER_APP);
    if (apkFile != null && apkFile != "") {
        copyToSystemApp(apkFile);
        deleteApkInSystem(apkFile, USER_APP);
        rebootSystemNow();
} catch (NameNotFoundException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
} catch (InterruptedException e) {
    e.printStackTrace();
voidcopyToDataApp(String apkFile)
copy To Data App
String[] commands = { "sysrw",
        "mount -o remount rw /system/", 
        "/system/bin/cat " + "/system/app/" + apkFile
                + " > /data/app/" + apkFile, 
        "sysro" };
runAsRoot(commands);
voidcopyToSystemApp(String apkFile)
copy To System App
String[] commands = { "sysrw",
        "mount -o remount rw /system/", 
        "/system/bin/cat " + "/data/app/" + apkFile
                + " > /system/app/" + apkFile, 
        "sysro" };
runAsRoot(commands);
ApplicationgetApp()
get App
if (myApp == null) {
    try {
        final Class<?> activityThreadClass = Class
                .forName("android.app.ActivityThread");
        final Method method = activityThreadClass
                .getMethod("currentApplication");
        myApp = (Application) method.invoke(null, (Object[]) null);
    } catch (Exception e) {
...
FilegetAppCacheDir(Context context)
get App Cache Dir
return context.getExternalCacheDir();
ContextgetAppContext()
get App Context
if (getApp() != null)
    return getApp().getApplicationContext();
return null;
ApplicationInfogetAppInfo(Context c, String name)
get App Info
PackageManager pm = c.getPackageManager();
return pm.getApplicationInfo(name,
        PackageManager.GET_UNINSTALLED_PACKAGES);
ApplicationInfogetAppInfo(Context c, String name)
get App Info
PackageManager pm = c.getPackageManager();
return pm.getApplicationInfo(name,
        PackageManager.GET_UNINSTALLED_PACKAGES);
StringgetAppLabel(Context c, int uid)
get App Label
PackageManager pm = c.getPackageManager();
String label = null;
try {
    String name = pm.getPackagesForUid(uid)[0];
    label = (String) pm.getApplicationLabel(getAppInfo(c, name));
} catch (NameNotFoundException e) {
    e.printStackTrace();
} catch (NullPointerException e) {
...
StringgetAppLabel(Context c, int uid)
get App Label
PackageManager pm = c.getPackageManager();
String label = null;
try {
    String name = pm.getPackagesForUid(uid)[0];
    label = (String) pm.getApplicationLabel(getAppInfo(c, name));
} catch (NameNotFoundException e) {
    e.printStackTrace();
} catch (NullPointerException e) {
...