当前位置: 首页>>代码示例>>Java>>正文


Java Activity.setTaskDescription方法代码示例

本文整理汇总了Java中android.app.Activity.setTaskDescription方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.setTaskDescription方法的具体用法?Java Activity.setTaskDescription怎么用?Java Activity.setTaskDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.setTaskDescription方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: styleRecentTasksEntry

import android.app.Activity; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void styleRecentTasksEntry(Activity activity) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return;
    }

    Resources resources = activity.getResources();
    String label = resources.getString(activity.getApplicationInfo().labelRes);
    int colorPrimary = resources.getColor(R.color.theme_primary);

    if (sIcon == null) {
        // Cache to avoid decoding the same bitmap on every Activity change
        sIcon = BitmapFactory.decodeResource(resources, R.drawable.ic_stat_notification);
    }

    activity.setTaskDescription(new ActivityManager.TaskDescription(label, sIcon, colorPrimary));
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:18,代码来源:RecentTasksStyler.java

示例2: fixTaskDescription

import android.app.Activity; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void fixTaskDescription(Activity activity, ActivityInfo targetInfo) {
    try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            PackageManager pm = mHostContext.getPackageManager();
            String lablel = String.valueOf(targetInfo.loadLabel(pm));
            Drawable icon = targetInfo.loadIcon(pm);
            Bitmap bitmap = null;
            if (icon instanceof BitmapDrawable) {
                bitmap = ((BitmapDrawable) icon).getBitmap();
            }
            if (bitmap != null) {
                activity.setTaskDescription(new android.app.ActivityManager.TaskDescription(lablel, bitmap));
            } else {
                activity.setTaskDescription(new android.app.ActivityManager.TaskDescription(lablel));
            }
        }
    } catch (Throwable e) {
        Log.w(TAG, "fixTaskDescription fail", e);
    }
}
 
开发者ID:amikey,项目名称:DroidPlugin,代码行数:22,代码来源:PluginInstrumentation.java

示例3: applyTaskDescription

import android.app.Activity; //导入方法依赖的package包/类
@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);
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:26,代码来源:ATE.java

示例4: applyTaskDescription

import android.app.Activity; //导入方法依赖的package包/类
@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) {

    }
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:14,代码来源:ATEUtils.java

示例5: injectTaskDescription

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 可根据插件Activity的描述(android:label、android:icon)来设置Task在“最近应用程序”中的显示 <p>
 * 注意:Android 4.x及以下暂不支持 <p>
 * Author: Jiongxuan Zhang
 */
private static void injectTaskDescription(Activity activity, ActivityInfo ai) {
    // Android 4.x及以下暂不支持
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return;
    }

    if (activity == null || ai == null) {
        return;
    }

    if (LOG) {
        LogDebug.d(TAG, "activity = " + activity);
        LogDebug.d(TAG, "ai = " + ai);
    }

    // 获取 activity label
    String label = getLabel(activity, ai);
    // 如果获取 label 失败(可能性极小),则不修改 TaskDescription
    if (TextUtils.isEmpty(label)) {
        return;
    }

    // 获取 ICON
    Bitmap bitmap = getIcon(activity, ai);

    // FIXME color的透明度需要在Theme中的colorPrimary中获取,先不实现
    ActivityManager.TaskDescription td;
    if (bitmap != null) {
        td = new ActivityManager.TaskDescription(label, bitmap);
    } else {
        td = new ActivityManager.TaskDescription(label);
    }

    if (LOG) {
        LogDebug.d(TAG, "td = " + td);
    }

    activity.setTaskDescription(td);
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:45,代码来源:ActivityInjector.java

示例6: getAppThemeExpanded

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Manipulate the application theme with TRASLUCENT actionbar:
 * Based on the corresponding theme (1-7) this method will:
 * set the theme
 * colorize the actionbar accordinlgy
 * adjust the padding of the icon
 * colorize (if >lollipop) the multitask
 * colorize (if>KK) the statusbar
 * <p/>
 * this returns a drawable that corresponds to the actionbar background
 * later to be manipulated by the corresponding activity
 *
 * @param context
 */
public static Drawable getAppThemeExpanded(final Activity context,
                                           Drawable mActionBarBackgroundDrawable) {

    int Theme = Integer.valueOf(PreferenceManager
            .getDefaultSharedPreferences(context).getString(
                    PreferencesActivity.KEY_THEME, "3"));

    mActionBarBackgroundDrawable = getThemeDrawable(context, Theme);

    if (Theme == 4) {
        context.setTheme(R.style.BlackTheme55);
    } else if (Theme == 1 || Theme == 7) {
        context.setTheme(R.style.CustomTheme55);
        context.getActionBar().setSplitBackgroundDrawable(
                mActionBarBackgroundDrawable);
        context.getActionBar().setStackedBackgroundDrawable(
                mActionBarBackgroundDrawable);
    } else {
        context.setTheme(R.style.ThunderMusic55);
        context.getActionBar().setSplitBackgroundDrawable(
                mActionBarBackgroundDrawable);
        context.getActionBar().setStackedBackgroundDrawable(
                mActionBarBackgroundDrawable);

    }

    ImageView view = (ImageView) context.findViewById(android.R.id.home);
    int paddingRight;

    if (context.getClass() == MediaPlaybackActivity.class) {
        paddingRight = (int) TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 16, context.getResources()
                        .getDisplayMetrics());
    } else {

        paddingRight = (int) TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, 24, context.getResources()
                        .getDisplayMetrics());
    }

    int paddingLeft = (int) TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP, 21, context.getResources()
                    .getDisplayMetrics());
    view.setPadding(paddingLeft, 0, paddingRight, 0);

    mActionBarBackgroundDrawable.setAlpha(0);
    context.getActionBar().setIcon(R.drawable.ic_action_back);
    context.getActionBar().setBackgroundDrawable(
            mActionBarBackgroundDrawable);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        if (Theme < 6)
            context.setTaskDescription(new ActivityManager.TaskDescription(
                    context.getString(R.string.musicbrowserlabel),
                    BitmapFactory.decodeResource(context.getResources(),
                            R.drawable.app_music), context.getResources()
                    .getColor(getThemeColor(context, Theme))));
        else
            context.setTaskDescription(new ActivityManager.TaskDescription(
                    context.getString(R.string.musicbrowserlabel),
                    BitmapFactory.decodeResource(context.getResources(),
                            R.drawable.app_music), getThemeColor(context,
                    Theme)));
    }
    return mActionBarBackgroundDrawable;
}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:82,代码来源:ThemeUtils.java

示例7: applyTaskDescription

import android.app.Activity; //导入方法依赖的package包/类
private static void applyTaskDescription(Activity target, ApkLoaded loaded) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Intent intent = target.getIntent();
        if (intent != null && target.isTaskRoot()) {
            String label = "" + loaded.getApkName();
            Bitmap icon = null;
            Drawable drawable = loaded.getApkIcon();
            if (drawable instanceof BitmapDrawable) {
                icon = ((BitmapDrawable) drawable).getBitmap();
            }
            target.setTaskDescription(new ActivityManager.TaskDescription(label, icon));
        }
    }
}
 
开发者ID:LiangMaYong,项目名称:android-apkbox,代码行数:15,代码来源:ApkActivityModifier.java


注:本文中的android.app.Activity.setTaskDescription方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。