List of usage examples for android.content.res Resources.NotFoundException toString
public String toString()
From source file:com.emetophobe.permissionviewer.PermissionScanner.java
@Override public void run() { // Get the list of installed packages PackageManager pm = mContext.getPackageManager(); List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); // Send a message to the main thread to display the progress dialog sendMessage(MESSAGE_PROGRESS_INIT, packages.size()); String packageName, appName, permissionName; PackageInfo packageInfo;//from ww w . j a v a 2 s. c o m boolean system; int count = 0; // Iterate over each package in the list for (ApplicationInfo appInfo : packages) { // Get the package name and label packageName = appInfo.packageName; try { appName = pm.getApplicationLabel(appInfo).toString(); } catch (Resources.NotFoundException e) { // application not found appName = packageName; } // Get the system flag system = (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; try { // Get the list of permissions packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS); if (packageInfo.requestedPermissions != null) { for (int i = 0; i < packageInfo.requestedPermissions.length; ++i) { if (packageInfo.requestedPermissions[i].startsWith(ANDROID_PERMISSION)) { permissionName = packageInfo.requestedPermissions[i] .substring(ANDROID_PERMISSION.length()); // Add a separate entry for each permission addPackage(appName, packageName, permissionName, system); } } } else { // Add an empty permission entry for packages that contain zero permissions addPackage(appName, packageName, null, system); } } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, e.toString()); } // Send a message to the main thread to update the progress dialog sendMessage(MESSAGE_PROGRESS_UPDATE, ++count); } // Send a message to the main thread that the thread is finished. sendMessage(MESSAGE_PROGRESS_COMPLETE, 0); }