Java Code Examples for android.content.pm.PackageManager#getDefaultActivityIcon()
The following examples show how to use
android.content.pm.PackageManager#getDefaultActivityIcon() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchDialog.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void updateSearchAppIcon() { PackageManager pm = getContext().getPackageManager(); Drawable icon; try { ActivityInfo info = pm.getActivityInfo(mLaunchComponent, 0); icon = pm.getApplicationIcon(info.applicationInfo); if (DBG) Log.d(LOG_TAG, "Using app-specific icon"); } catch (NameNotFoundException e) { icon = pm.getDefaultActivityIcon(); Log.w(LOG_TAG, mLaunchComponent + " not found, using generic app icon"); } mAppIcon.setImageDrawable(icon); mAppIcon.setVisibility(View.VISIBLE); mSearchPlate.setPadding(SEARCH_PLATE_LEFT_PADDING_NON_GLOBAL, mSearchPlate.getPaddingTop(), mSearchPlate.getPaddingRight(), mSearchPlate.getPaddingBottom()); }
Example 2
Source File: IconCache.java From Taskbar with Apache License 2.0 | 5 votes |
private Drawable getIcon(PackageManager pm, LauncherActivityInfo appInfo) { try { return appInfo.getBadgedIcon(0); } catch (NullPointerException e) { return pm.getDefaultActivityIcon(); } }
Example 3
Source File: AppInfo.java From island with Apache License 2.0 | 5 votes |
private Drawable loadUnbadgedIconCompat(final PackageManager pm) { if (SDK_INT >= LOLLIPOP_MR1) try { return loadUnbadgedIcon(pm); } catch (final SecurityException e) { // Appears on some Samsung devices (e.g. Galaxy S7, Note 8) with Android 8.0 Analytics.$().logAndReport(TAG, "Error loading unbadged icon for " + this, e); } Drawable dr = null; if (packageName != null) dr = pm.getDrawable(packageName, icon, this); if (dr == null) dr = pm.getDefaultActivityIcon(); return dr; }
Example 4
Source File: LabelManagerPackageActivity.java From talkback with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.label_manager_labels); final Intent intent = getIntent(); if (!intent.hasExtra(EXTRA_PACKAGE_NAME)) { throw new IllegalArgumentException("Intent missing package name extra."); } packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME); final PackageManager packageManager = getPackageManager(); CharSequence applicationLabel; Drawable packageIcon; try { packageIcon = packageManager.getApplicationIcon(packageName); final PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0); applicationLabel = packageManager.getApplicationLabel(packageInfo.applicationInfo); } catch (NameNotFoundException e) { LogUtils.i(TAG, "Could not load package info for package %s.", packageName); packageIcon = packageManager.getDefaultActivityIcon(); applicationLabel = packageName; } setTitle(getString(R.string.label_manager_package_title, applicationLabel)); final ActionBar actionBar = getSupportActionBar(); actionBar.setIcon(packageIcon); actionBar.setDisplayHomeAsUpEnabled(true); labelList = (ListView) findViewById(R.id.label_list); labelProviderClient = new LabelProviderClient(this, LabelProvider.AUTHORITY); }
Example 5
Source File: ApkItem.java From DroidPlugin with GNU Lesser General Public License v3.0 | 5 votes |
ApkItem(PackageManager pm, PackageInfo info, String path) { try { icon = pm.getApplicationIcon(info.applicationInfo); } catch (Exception e) { icon = pm.getDefaultActivityIcon(); } title = pm.getApplicationLabel(info.applicationInfo); versionName = info.versionName; versionCode = info.versionCode; apkfile = path; packageInfo = info; }
Example 6
Source File: IconListAdapter.java From ActivityLauncher with ISC License | 5 votes |
static Drawable getIcon(String icon_resource_string, PackageManager pm) { try { String pack = icon_resource_string.substring(0, icon_resource_string.indexOf(':')); String type = icon_resource_string.substring(icon_resource_string.indexOf(':') + 1, icon_resource_string.indexOf('/')); String name = icon_resource_string.substring(icon_resource_string.indexOf('/') + 1); Resources res = pm.getResourcesForApplication(pack); return res.getDrawable(res.getIdentifier(name, type, pack)); } catch (Exception e) { return pm.getDefaultActivityIcon(); } }