use of android.content.pm.PackageInfo in project bee by orhanobut.
the class UiHandler method createInfoContent.
/**
* It is called when the predefined information is created
*
* @return map which contains some predefined information
*/
private Map<String, String> createInfoContent() {
PackageInfo packageInfo;
Map<String, String> content = new LinkedHashMap<>();
try {
PackageManager packageManager = context.getPackageManager();
packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
Log.d(TAG, "name not found");
return content;
}
content.put("Package Name", packageInfo.packageName);
content.put("Version Name", packageInfo.versionName);
content.put("Version Code", "" + packageInfo.versionCode);
content.put("First Install Time", new Date(packageInfo.firstInstallTime).toString());
content.put("Update Time", new Date(packageInfo.lastUpdateTime).toString());
content.put("Android Version", Build.VERSION.RELEASE);
content.put("Display", Build.DISPLAY);
content.put("Device Model", Build.MODEL);
return content;
}
use of android.content.pm.PackageInfo in project superCleanMaster by joyoyao.
the class AppUtil method getVersionCode.
public static int getVersionCode(Context context) {
try {
PackageManager manager = context.getPackageManager();
PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
int versionCode = info.versionCode;
return versionCode;
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
use of android.content.pm.PackageInfo in project superCleanMaster by joyoyao.
the class AppUtil method getRunningAppProcesses.
/**
* 描述:获取运行的进程列表.
*
* @param context
* @return
*/
public static List<AppProcessInfo> getRunningAppProcesses(Context context) {
ActivityManager activityManager = null;
List<AppProcessInfo> list = null;
PackageManager packageManager = null;
try {
activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
packageManager = context.getApplicationContext().getPackageManager();
list = new ArrayList<AppProcessInfo>();
// 所有运行的进程
List<RunningAppProcessInfo> appProcessList = activityManager.getRunningAppProcesses();
ApplicationInfo appInfo = null;
AppProcessInfo abAppProcessInfo = null;
PackageInfo packageInfo = getPackageInfo(context);
if (mProcessList != null) {
mProcessList.clear();
}
mProcessList = getProcessRunningInfo();
for (RunningAppProcessInfo appProcessInfo : appProcessList) {
abAppProcessInfo = new AppProcessInfo(appProcessInfo.processName, appProcessInfo.pid, appProcessInfo.uid);
appInfo = getApplicationInfo(context, appProcessInfo.processName);
if (appInfo != null) {
if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
abAppProcessInfo.isSystem = true;
} else {
abAppProcessInfo.isSystem = false;
}
Drawable icon = appInfo.loadIcon(packageManager);
String appName = appInfo.loadLabel(packageManager).toString();
abAppProcessInfo.icon = icon;
abAppProcessInfo.appName = appName;
} else {
// :服务的命名
if (appProcessInfo.processName.indexOf(":") != -1) {
appInfo = getApplicationInfo(context, appProcessInfo.processName.split(":")[0]);
Drawable icon = appInfo.loadIcon(packageManager);
abAppProcessInfo.icon = icon;
}
abAppProcessInfo.isSystem = true;
abAppProcessInfo.appName = appProcessInfo.processName;
}
/*
* AbPsRow psRow = getPsRow(appProcessInfo.processName);
* if(psRow!=null){ abAppProcessInfo.memory = psRow.mem; }
*/
ProcessInfo processInfo = getMemInfo(appProcessInfo.processName);
abAppProcessInfo.memory = processInfo.memory;
abAppProcessInfo.cpu = processInfo.cpu;
abAppProcessInfo.status = processInfo.status;
abAppProcessInfo.threadsCount = processInfo.threadsCount;
list.add(abAppProcessInfo);
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
use of android.content.pm.PackageInfo in project superCleanMaster by joyoyao.
the class AppUtil method getVersion.
public static String getVersion(Context context) {
try {
PackageManager manager = context.getPackageManager();
PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
String version = info.versionName;
return version;
} catch (Exception e) {
e.printStackTrace();
return "1.0";
}
}
use of android.content.pm.PackageInfo in project QLibrary by DragonsQC.
the class AppUtils method getPackageInfo.
/**
* 获得当前APP PackageInfo 对象
*
* @return PackageInfo 对象
*/
public PackageInfo getPackageInfo(Context context) {
PackageManager manager = context.getApplicationContext().getPackageManager();
PackageInfo info = null;
try {
info = manager.getPackageInfo(context.getApplicationContext().getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return info;
}
Aggregations