List of usage examples for android.appwidget AppWidgetProviderInfo loadPreviewImage
public final Drawable loadPreviewImage(@NonNull Context context, int density)
From source file:com.farmerbb.taskbar.service.DashboardService.java
private void addPlaceholder(int cellId) { FrameLayout placeholder = (FrameLayout) cells.get(cellId).findViewById(R.id.placeholder); SharedPreferences pref = U.getSharedPreferences(this); String providerName = pref.getString("dashboard_widget_" + Integer.toString(cellId) + "_provider", "null"); if (!providerName.equals("null")) { ImageView imageView = (ImageView) placeholder.findViewById(R.id.placeholder_image); ComponentName componentName = ComponentName.unflattenFromString(providerName); List<AppWidgetProviderInfo> providerInfoList = mAppWidgetManager .getInstalledProvidersForProfile(Process.myUserHandle()); for (AppWidgetProviderInfo info : providerInfoList) { if (info.provider.equals(componentName)) { Drawable drawable = info.loadPreviewImage(this, -1); if (drawable == null) drawable = info.loadIcon(this, -1); ColorMatrix matrix = new ColorMatrix(); matrix.setSaturation(0); imageView.setImageDrawable(drawable); imageView.setColorFilter(new ColorMatrixColorFilter(matrix)); break; }/*from www. j a v a 2 s. c o m*/ } } placeholder.setVisibility(View.VISIBLE); }