Example usage for android.app Activity setTaskDescription

List of usage examples for android.app Activity setTaskDescription

Introduction

In this page you can find the example usage for android.app Activity setTaskDescription.

Prototype

public void setTaskDescription(ActivityManager.TaskDescription taskDescription) 

Source Link

Document

Sets information describing the task with this activity for presentation inside the Recents System UI.

Usage

From source file:Main.java

public static void setTaskDescription(final Activity activity, final String label, final int icon,
        final int color) {
    activity.setTaskDescription(new ActivityManager.TaskDescription(label,
            BitmapFactory.decodeResource(activity.getResources(), icon), color));
}

From source file:Main.java

/**
 * @param activity Activity that should get the task description update.
 * @param title Title of the activity.// www.jav  a2s.  c  om
 * @param icon Icon of the activity.
 * @param color Color of the activity. It must be a fully opaque color.
 */
public static void setTaskDescription(Activity activity, String title, Bitmap icon, int color) {
    // TaskDescription requires an opaque color.
    assert Color.alpha(color) == 255;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ActivityManager.TaskDescription description = new ActivityManager.TaskDescription(title, icon, color);
        activity.setTaskDescription(description);
    }
}

From source file:com.ruesga.rview.misc.AndroidHelper.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void configureTaskDescription(Activity activity) {
    if (isLollipopOrGreater()) {
        Bitmap icon = BitmapFactory.decodeResource(activity.getResources(), R.mipmap.ic_launcher);
        TaskDescription taskDesc = new TaskDescription(null, icon,
                ContextCompat.getColor(activity, R.color.primaryDark));
        activity.setTaskDescription(taskDesc);
    }//from  w  ww.j  a  v a 2  s . c om
}

From source file:com.actinarium.nagbox.common.ViewUtils.java

/**
 * Set custom icon and color for recents screen card
 *
 * @param activity Activity to configure
 * @param colorRes Color resource for recents screen card title
 * @param icon     Bitmap drawable resource to draw into recents screen card title
 *//*ww  w .j a va 2s  .co m*/
public static void setupRecentsIcon(Activity activity, @ColorRes int colorRes, @DrawableRes int icon) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return;
    }

    int color = ContextCompat.getColor(activity, colorRes);
    Bitmap bm = BitmapFactory.decodeResource(activity.getResources(), icon);
    ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(null, bm, color);

    activity.setTaskDescription(td);
    bm.recycle();
}

From source file:com.google.samples.apps.iosched.util.RecentTasksStyler.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void styleRecentTasksEntry(Activity activity) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return;//  ww w .j ava  2  s .  co  m
    }

    final String label = activity.getString(activity.getApplicationInfo().labelRes);
    final int colorPrimary = UIUtils.getThemeColor(activity, R.attr.colorPrimary, R.color.theme_primary);
    if (sIcon == null) {
        // Cache to avoid decoding the same bitmap on every Activity change
        sIcon = UIUtils.vectorToBitmap(activity, R.drawable.ic_recents_logo);
    }
    activity.setTaskDescription(new ActivityManager.TaskDescription(label, sIcon, colorPrimary));
}

From source file:com.ming.slove.mvnew.app.ThemeHelper.java

public static CardPickerDialog.ClickListener getCardPickerListener(final Context context) {
    return new CardPickerDialog.ClickListener() {
        @Override//w  w  w.  jav a  2  s.  co m
        public void onConfirm(int currentTheme) {
            if (ThemeHelper.getTheme(context) != currentTheme) {
                ThemeHelper.setTheme(context, currentTheme);
                ThemeUtils.refreshUI(context, new ThemeUtils.ExtraRefreshable() {
                    @Override
                    public void refreshGlobal(Activity activity) {
                        if (Build.VERSION.SDK_INT >= 21) {
                            ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(
                                    null, null,
                                    ThemeUtils.getThemeAttrColor(context, android.R.attr.colorPrimary));
                            activity.setTaskDescription(taskDescription);
                            activity.getWindow().setStatusBarColor(
                                    ThemeUtils.getColorById(context, R.color.theme_color_primary));
                        }
                    }

                    @Override
                    public void refreshSpecificView(View view) {
                    }
                });
                //MainActivity?
                EventBus.getDefault().post(new ChangeThemeColorEvent());
            }
        }
    };
}

From source file:com.bt.heliniumstudentapp.MainActivity.java

protected static void setStatusBar(Activity context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        context.getWindow().setStatusBarColor(Color.TRANSPARENT);

        if (context == mainContext)
            drawerDL.setStatusBarBackgroundColor(ContextCompat.getColor(context, darkPrimaryColor));
        else//from  w  w w . ja v a  2s  .co  m
            context.getWindow().setStatusBarColor(ContextCompat.getColor(context, darkPrimaryColor));

        context.setTaskDescription(new ActivityManager.TaskDescription(context.getString(R.string.app_name),
                BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher),
                ContextCompat.getColor(context, primaryColor)));

    }
}