本文整理了Java中android.app.Activity.setTaskDescription()
方法的一些代码示例,展示了Activity.setTaskDescription()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.setTaskDescription()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:setTaskDescription
暂无
代码示例来源:origin: naman14/Timber
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void applyTaskDescription(@NonNull Activity activity, @Nullable String key, int color) {
// Sets color of entry in the system recents page
try {
ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
(String) activity.getTitle(),
((BitmapDrawable) activity.getApplicationInfo().loadIcon(activity.getPackageManager())).getBitmap(),
color);
activity.setTaskDescription(td);
} catch (Exception ignored) {
}
}
代码示例来源:origin: android-hacker/VirtualXposed
icon = ((BitmapDrawable) drawable).getBitmap();
activity.setTaskDescription(new ActivityManager.TaskDescription(label, icon));
} catch (Throwable e) {
e.printStackTrace();
代码示例来源:origin: WangDaYeeeeee/Mysplash
public static void setWindowTop(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Bitmap icon = BitmapFactory.decodeResource(activity.getResources(), R.drawable.ic_launcher);
ActivityManager.TaskDescription taskDescription
= new ActivityManager.TaskDescription(
activity.getString(R.string.app_name),
icon,
ThemeManager.getPrimaryColor(activity));
activity.setTaskDescription(taskDescription);
icon.recycle();
}
}
代码示例来源:origin: WangDaYeeeeee/GeometricWeather
public static void setWindowTopColor(Activity a, @ColorInt int color) {
if (color == 0) {
ContextCompat.getColor(a, R.color.colorPrimary);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int c = a instanceof MainActivity ?
color : ContextCompat.getColor(a, R.color.colorPrimary);
ActivityManager.TaskDescription taskDescription;
Bitmap topIcon = BitmapFactory.decodeResource(a.getResources(), R.drawable.ic_launcher);
taskDescription = new ActivityManager.TaskDescription(
a.getString(R.string.geometric_weather),
topIcon,
c);
a.setTaskDescription(taskDescription);
topIcon.recycle();
}
}
代码示例来源:origin: iAcn/BiliNeat
public static void updateTaskColor(Activity activity) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return;
String label = activity.getTitle().toString().trim();
Bitmap icon = BitmapFactory.decodeResource(activity.getResources(), R.mipmap.ic_launcher);
if (TextUtils.isEmpty(label)) {
label = activity.getResources().getString(R.string.app_name);
}
activity.setTaskDescription(new ActivityManager.TaskDescription(label, icon, getPrimaryColor()));
}
}
代码示例来源:origin: xtools-at/Android-PWA-Wrapper
public void changeRecentAppsIcon() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Bitmap iconWhite = BitmapFactory.decodeResource(activity.getResources(), R.drawable.ic_appbar);
TypedValue typedValue = new TypedValue();
Resources.Theme theme = activity.getTheme();
theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
int color = typedValue.data;
ActivityManager.TaskDescription description = new ActivityManager.TaskDescription(
activity.getResources().getString(R.string.app_name),
iconWhite,
color
);
activity.setTaskDescription(description);
iconWhite.recycle();
}
}
}
代码示例来源:origin: marverenic/Colors
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
private static void applyTaskDescription(Activity activity, @Nullable String taskName,
@Nullable Bitmap taskIcon) {
@ColorRes int primaryColorRes = sTheme.getPrimaryColor().getPrimaryColorRes();
@ColorInt int primaryColor = ContextCompat.getColor(activity, primaryColorRes);
TaskDescription taskDescription = new TaskDescription(taskName, taskIcon, primaryColor);
activity.setTaskDescription(taskDescription);
}
代码示例来源:origin: malmstein/yahnac
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setTaskDescriptionOnLollipopAndLater() {
if (isAtLeastLollipop()) {
TaskDescription taskDescription = createTaskDescription();
activity.setTaskDescription(taskDescription);
}
}
代码示例来源:origin: armcha/Vertical-Intro
static void setUpRecentAppStyle(Activity activity, int targetColor) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
try {
Drawable appIcon = activity.getPackageManager().getApplicationIcon(activity.getPackageName());
Bitmap bm = getBitmapFromDrawable(appIcon);
int recentAppsStyleColor = ContextCompat.getColor(activity, targetColor);
ActivityManager.TaskDescription taskDescription =
new ActivityManager.TaskDescription(
activity.getString(R.string.app_name), bm, recentAppsStyleColor);
activity.setTaskDescription(taskDescription);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: rohanoid5/Muzesto
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void applyTaskDescription(@NonNull Activity activity, @Nullable String key, int color) {
// Sets color of entry in the system recents page
try {
ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
(String) activity.getTitle(),
((BitmapDrawable) activity.getApplicationInfo().loadIcon(activity.getPackageManager())).getBitmap(),
color);
activity.setTaskDescription(td);
} catch (Exception ignored) {
}
}
代码示例来源:origin: brainysoon/cyberCar
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void applyTaskDescription(@NonNull Activity activity, @Nullable String key, int color) {
// Sets color of entry in the system recents page
try {
ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
(String) activity.getTitle(),
((BitmapDrawable) activity.getApplicationInfo().loadIcon(activity.getPackageManager())).getBitmap(),
color);
activity.setTaskDescription(td);
} catch (Exception ignored) {
}
}
代码示例来源:origin: cbeyls/fosdem-companion-android
@SuppressWarnings("deprecation")
public static void setStatusBarTrackColor(@NonNull Activity activity, @NonNull Track.Type trackType) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final int color = ContextCompat.getColor(activity, trackType.getColorResId());
final int darkColor = ContextCompat.getColor(activity, trackType.getDarkColorResId());
activity.getWindow().setStatusBarColor(darkColor);
final ActivityManager.TaskDescription taskDescription;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
taskDescription = new ActivityManager.TaskDescription(null, 0, color | 0xFF000000);
} else {
taskDescription = new ActivityManager.TaskDescription(null, null, color | 0xFF000000);
}
activity.setTaskDescription(taskDescription);
}
}
}
代码示例来源:origin: jruesga/rview
@TargetApi(Build.VERSION_CODES.P)
@SuppressLint("Deprecated")
public static void configureTaskDescription(Activity activity) {
if (isLollipopOrGreater()) {
final TaskDescription taskDesc;
if (isApi28OrGreater()) {
taskDesc = new TaskDescription(null, R.mipmap.ic_launcher,
ContextCompat.getColor(activity, R.color.primaryDark));
} else {
Bitmap icon = BitmapFactory.decodeResource(
activity.getResources(), R.mipmap.ic_launcher);
taskDesc = new TaskDescription(
null, icon, ContextCompat.getColor(activity, R.color.primaryDark));
}
activity.setTaskDescription(taskDesc);
}
}
代码示例来源:origin: xuancao/DynamicSkin
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void applyTaskDescription(@NonNull Activity activity, @Nullable String key) {
int color;
Bitmap icon = null;
if (activity instanceof ATETaskDescriptionCustomizer) {
final ATETaskDescriptionCustomizer customizer = (ATETaskDescriptionCustomizer) activity;
color = customizer.getTaskDescriptionColor();
icon = customizer.getTaskDescriptionIcon();
} else {
color = Config.primaryColor(activity, key);
}
// Task description requires fully opaque color
color = Util.stripAlpha(color);
// Default is app's launcher icon
if (icon == null)
icon = ((BitmapDrawable) activity.getApplicationInfo().loadIcon(activity.getPackageManager())).getBitmap();
// Sets color of entry in the system recents page
ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
(String) activity.getTitle(), icon, color);
activity.setTaskDescription(td);
}
代码示例来源:origin: garretyoder/app-theme-engine
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void applyTaskDescription(@NonNull Activity activity, @Nullable String key) {
int color = 0;
Bitmap icon = null;
if (activity instanceof ATETaskDescriptionCustomizer) {
final ATETaskDescriptionCustomizer customizer = (ATETaskDescriptionCustomizer) activity;
color = customizer.getTaskDescriptionColor();
icon = customizer.getTaskDescriptionIcon();
if (color == ATE.USE_DEFAULT)
color = Config.primaryColor(activity, key);
} else {
color = Config.primaryColor(activity, key);
}
// Task description requires fully opaque color
color = ATEUtil.stripAlpha(color);
// Default is app's launcher icon
if (icon == null)
icon = ((BitmapDrawable) activity.getApplicationInfo().loadIcon(activity.getPackageManager())).getBitmap();
// Sets color of entry in the system recents page
ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
(String) activity.getTitle(), icon, color);
activity.setTaskDescription(td);
}
代码示例来源:origin: darkskygit/VirtualApp
icon = ((BitmapDrawable) drawable).getBitmap();
activity.setTaskDescription(new ActivityManager.TaskDescription(label, icon));
} catch (Throwable e) {
e.printStackTrace();
代码示例来源:origin: bzsome/VirtualApp-x326
icon = ((BitmapDrawable) drawable).getBitmap();
activity.setTaskDescription(new ActivityManager.TaskDescription(label, icon));
} catch (Throwable e) {
e.printStackTrace();
内容来源于网络,如有侵权,请联系作者删除!