use of android.content.pm.PackageManager.NameNotFoundException in project XPrivacy by M66B.
the class Util method getSelfVersionName.
public static String getSelfVersionName(Context context) {
try {
String self = Util.class.getPackage().getName();
PackageManager pm = context.getPackageManager();
PackageInfo pInfo = pm.getPackageInfo(self, 0);
return pInfo.versionName;
} catch (NameNotFoundException ex) {
Util.bug(null, ex);
return null;
}
}
use of android.content.pm.PackageManager.NameNotFoundException in project XPrivacy by M66B.
the class Util method getSelfVersionCode.
public static int getSelfVersionCode(Context context) {
try {
String self = Util.class.getPackage().getName();
PackageManager pm = context.getPackageManager();
PackageInfo pInfo = pm.getPackageInfo(self, 0);
return pInfo.versionCode;
} catch (NameNotFoundException ex) {
Util.bug(null, ex);
return 0;
}
}
use of android.content.pm.PackageManager.NameNotFoundException in project Xposed-Tinted-Status-Bar by MohammadAG.
the class PackageListActivity method loadApps.
@SuppressLint("DefaultLocale")
private void loadApps(ProgressDialog dialog) {
mAppList.clear();
PackageManager pm = getPackageManager();
List<ApplicationInfo> apps = getPackageManager().getInstalledApplications(0);
dialog.setMax(apps.size());
int i = 1;
for (ApplicationInfo appInfo : apps) {
dialog.setProgress(i++);
if (appInfo == null)
continue;
appInfo.name = appInfo.loadLabel(pm).toString();
try {
/* Slower app startup, but fewer apps for the user to go through */
PackageInfo pkgInfo = pm.getPackageInfo(appInfo.packageName, PackageManager.GET_ACTIVITIES);
ActivityInfo[] list = pkgInfo.activities;
if (list != null)
mAppList.add(appInfo);
} catch (NameNotFoundException e) {
continue;
}
}
ApplicationInfo lockscreenStub = new ApplicationInfo();
lockscreenStub.name = getString(R.string.android_lockscreen_stub_name);
lockscreenStub.packageName = PackageNames.LOCKSCREEN_STUB;
mAppList.add(lockscreenStub);
Collections.sort(mAppList, new Comparator<ApplicationInfo>() {
@SuppressLint("DefaultLocale")
@Override
public int compare(ApplicationInfo lhs, ApplicationInfo rhs) {
if (lhs.name == null) {
return -1;
} else if (rhs.name == null) {
return 1;
} else {
return lhs.name.toUpperCase().compareTo(rhs.name.toUpperCase());
}
}
});
}
use of android.content.pm.PackageManager.NameNotFoundException in project Inscription by MartinvanZ.
the class ChangeLogDialog method getHTML.
//Returns change log in HTML format
public String getHTML() {
//TODO: Remove duplicate code with the method show()
//Get resources
final String packageName = mContext.getPackageName();
final Resources resources;
try {
resources = mContext.getPackageManager().getResourcesForApplication(packageName);
} catch (NameNotFoundException ignored) {
return "";
}
//Create HTML change log
return getHTMLChangelog(R.xml.changelog, resources, 0);
}
use of android.content.pm.PackageManager.NameNotFoundException in project android_frameworks_base by ParanoidAndroid.
the class BackupManagerService method allAgentPackages.
// Returns the set of all applications that define an android:backupAgent attribute
List<PackageInfo> allAgentPackages() {
// !!! TODO: cache this and regenerate only when necessary
int flags = PackageManager.GET_SIGNATURES;
List<PackageInfo> packages = mPackageManager.getInstalledPackages(flags);
int N = packages.size();
for (int a = N - 1; a >= 0; a--) {
PackageInfo pkg = packages.get(a);
try {
ApplicationInfo app = pkg.applicationInfo;
if (((app.flags & ApplicationInfo.FLAG_ALLOW_BACKUP) == 0) || app.backupAgentName == null) {
packages.remove(a);
} else {
// we will need the shared library path, so look that up and store it here
app = mPackageManager.getApplicationInfo(pkg.packageName, PackageManager.GET_SHARED_LIBRARY_FILES);
pkg.applicationInfo.sharedLibraryFiles = app.sharedLibraryFiles;
}
} catch (NameNotFoundException e) {
packages.remove(a);
}
}
return packages;
}
Aggregations