當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。