當前位置: 首頁>>代碼示例>>Java>>正文


Java Icon類代碼示例

本文整理匯總了Java中android.graphics.drawable.Icon的典型用法代碼示例。如果您正苦於以下問題:Java Icon類的具體用法?Java Icon怎麽用?Java Icon使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Icon類屬於android.graphics.drawable包,在下文中一共展示了Icon類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createShortcutForAndroidN

import android.graphics.drawable.Icon; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
private void createShortcutForAndroidN() {
    Icon icon;
    if (mIsDefaultIcon) {
        icon = Icon.createWithResource(this, R.drawable.ic_node_js_black);
    } else {
        Bitmap bitmap = BitmapTool.drawableToBitmap(mIcon.getDrawable());
        icon = Icon.createWithBitmap(bitmap);
    }
    PersistableBundle extras = new PersistableBundle(1);
    extras.putString(ScriptIntents.EXTRA_KEY_PATH, mScriptFile.getPath());
    ShortcutManager.getInstance(this).addDynamicShortcut(mName.getText(), mScriptFile.getPath(), icon,
            new Intent(this, ShortcutActivity.class)
                    .putExtra(ScriptIntents.EXTRA_KEY_PATH, mScriptFile.getPath())
                    .setAction(Intent.ACTION_MAIN));
}
 
開發者ID:hyb1996,項目名稱:Auto.js,代碼行數:17,代碼來源:ShortcutCreateActivity.java

示例2: updateDynamicShortcuts

import android.graphics.drawable.Icon; //導入依賴的package包/類
/**
 * Update the dynamic shortcuts that are associated with this app. The given list of cards must
 * be sorted by popularity. The amount parameter indicates how much shortcuts should be made.
 *
 * @param cards A list of cards that's sorted by popularity.
 * @param amount Amount indicates the number n of cards for which a shortcut should be made from
 *               the list.
 */
public void updateDynamicShortcuts(List<Card> cards, int amount) {
    if (cards.size() < amount) {
        amount = cards.size();
    }

    this.cards = cards;

    List<ShortcutInfo> shortcuts = new ArrayList<>();

    ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);


    for (int i = 0; i < amount; i++) {
        ShortcutInfo shortcut = new ShortcutInfo.Builder(context, cards.get(i).getName() + "-shortcut")
                .setShortLabel(cards.get(i).getName())
                .setIcon(Icon.createWithResource(context, R.drawable.shortcut_store))
                .setIntent(createCardShortcutIntent(cards.get(i)))
                .build();
        shortcuts.add(shortcut);
    }

    shortcutManager.setDynamicShortcuts(shortcuts);
}
 
開發者ID:AbyxBelgium,項目名稱:Loyalty,代碼行數:32,代碼來源:LauncherInfoManager.java

示例3: createShortcut

import android.graphics.drawable.Icon; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.N_MR1)
private void createShortcut(String label, String packageName, Bitmap icon, Intent intent) {
    ShortcutManager shortcutManager;
    shortcutManager = getSystemService(ShortcutManager.class);

    ShortcutInfo shortcut = new ShortcutInfo.Builder(this, packageName)
            .setShortLabel(label)
            .setLongLabel(label)
            .setIcon(Icon.createWithBitmap(icon))
            .setIntent(intent)
            .setRank(0)
            .build();

    List<ShortcutInfo> shortcutList = shortcutManager.getDynamicShortcuts();
    int shortcutSize = shortcutList.size();

    if (shortcutSize >= 5) {
        for (int i = 0; i < shortcutSize - 4; i++) {
            shortcutManager.removeDynamicShortcuts(Collections.singletonList(shortcutList.get(0).getId()));
        }
    }
    shortcutManager.addDynamicShortcuts(Collections.singletonList(shortcut));
}
 
開發者ID:frowhy,項目名稱:Wake,代碼行數:24,代碼來源:WakeActivity.java

示例4: createShortcut

import android.graphics.drawable.Icon; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.N_MR1)
private void createShortcut() {
    ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);

    Intent intent = new Intent(this, SplashActivity.class);
    intent.setAction(ACTION_QUICK_START_OR_QUICK_STOP);
    intent.putExtra(EXTRA_COME_FROM_SHORTCUT, true);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);

    ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "shortcut_quick_switch")
            .setShortLabel(getString(R.string.shortcut_quick_switch))
            .setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher))
            .setIntent(intent)
            .build();

    if (shortcutManager != null) {
        shortcutManager.setDynamicShortcuts(Collections.singletonList(shortcut));
    }
}
 
開發者ID:Omico,項目名稱:CurrentActivity,代碼行數:20,代碼來源:SplashActivity.java

示例5: updateTileState

import android.graphics.drawable.Icon; //導入依賴的package包/類
private void updateTileState(int state) {
    Tile tile = getQsTile();
    if (tile != null) {
        tile.setState(state);
        Icon icon = tile.getIcon();
        switch (state) {
            case Tile.STATE_ACTIVE:
                icon.setTint(Color.WHITE);
                break;
            case Tile.STATE_INACTIVE:
            case Tile.STATE_UNAVAILABLE:
            default:
                icon.setTint(Color.GRAY);
                break;
        }
        tile.updateTile();
    }
}
 
開發者ID:kranthi0987,項目名稱:easyfilemanager,代碼行數:19,代碼來源:ServerService.java

示例6: registerNewPhoneAccount

import android.graphics.drawable.Icon; //導入依賴的package包/類
/**
 * Create a new {@link PhoneAccount} and register it with the system.
 *
 * @param context     The context to use for finding the services and resources.
 * @param accountName The name of the account to add - must be an international phonenumber.
 */
public static void registerNewPhoneAccount(Context context, String accountName) {
    PhoneAccountHandle accountHandle = createPhoneAccountHandle(context, accountName);

    PhoneAccount phone = PhoneAccount.builder(accountHandle, context.getResources().getString(R.string.app_name))
            .setIcon(Icon.createWithResource(context, R.mipmap.ic_launcher_round))
            .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
            .addSupportedUriScheme(PhoneAccount.SCHEME_SIP)
            .setAddress(Uri.parse("sip:" + accountName))
            .build();

    TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);

    telecomManager.registerPhoneAccount(phone);

    // Let the user enable our phone account
    // TODO Show toast so the user knows what is happening
    context.startActivity(new Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS));
}
 
開發者ID:Aentfs,項目名稱:Phony-Android,代碼行數:25,代碼來源:PhonyUtil.java

示例7: createShortcutList

import android.graphics.drawable.Icon; //導入依賴的package包/類
public ShortcutHelper createShortcutList(@NonNull List<Shortcut> shortcuts) {
    if (Build.VERSION.SDK_INT < 25) {
        return this;
    }
    mShortcutManager = mActivity.getSystemService(ShortcutManager.class);
    for (int i=0; i<shortcuts.size(); i++) {
        if (i < mShortcutManager.getMaxShortcutCountPerActivity()) {
            String shortcutId = shortcuts.get(i).getShortLabel().replaceAll("\\s+","").toLowerCase() + "_shortcut";
            ShortcutInfo shortcut = new ShortcutInfo.Builder(mActivity, shortcutId)
                    .setShortLabel(shortcuts.get(i).getShortLabel())
                    .setLongLabel(shortcuts.get(i).getLongLabel())
                    .setIcon(Icon.createWithResource(mActivity, shortcuts.get(i).getIconResource()))
                    .setIntent(shortcuts.get(i).getIntent())
                    .build();
            mShortcutInfos.add(shortcut);
        }
    }
    return this;
}
 
開發者ID:marcoscgdev,項目名稱:shortcut-helper,代碼行數:20,代碼來源:ShortcutHelper.java

示例8: createShortcuts

import android.graphics.drawable.Icon; //導入依賴的package包/類
public static List<List<ShortcutInfo>> createShortcuts(Context context) {
    List<ShortcutInfo> enabledShortcuts = new ArrayList<>();
    List<ShortcutInfo> disabledShortcuts = new ArrayList<>();
    enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID")
            .setShortLabel(context.getString(34))
            .setLongLabel(context.getString(56))
            .setIcon(Icon.createWithResource(context, 12))
            .setDisabledMessage(context.getString(78))
            .setIntents(TaskStackBuilder.create(context)
                    .addParentStack(ResourcesShortcutActivity.class)
                    .addNextIntent(new Intent(context, ResourcesShortcutActivity.class)
                            .setAction(Intent.ACTION_VIEW))
                    .getIntents())
            .setRank(0)
            .build());
    return Arrays.asList(enabledShortcuts, disabledShortcuts);
}
 
開發者ID:MatthiasRobbers,項目名稱:shortbread,代碼行數:18,代碼來源:ResourcesShortcutActivityGenerated.java

示例9: createShortcuts

import android.graphics.drawable.Icon; //導入依賴的package包/類
public static List<List<ShortcutInfo>> createShortcuts(Context context) {
    List<ShortcutInfo> enabledShortcuts = new ArrayList<>();
    List<ShortcutInfo> disabledShortcuts = new ArrayList<>();
    enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID")
            .setShortLabel(ShortcutUtils.getActivityLabel(context, SimpleShortcutActivity.class))
            .setIntents(TaskStackBuilder.create(context)
                    .addParentStack(SimpleShortcutActivity.class)
                    .addNextIntent(new Intent(context, SimpleShortcutActivity.class)
                            .setAction(Intent.ACTION_VIEW))
                    .getIntents())
            .setRank(0)
            .build());
    enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID_2")
            .setShortLabel("SHORT_LABEL")
            .setLongLabel("LONG_LABEL")
            .setIcon(Icon.createWithResource(context, 123))
            .setDisabledMessage("DISABLED_MESSAGE")
            .setIntents(TaskStackBuilder.create(context)
                    .addParentStack(AdvancedShortcutActivity.class)
                    .addNextIntent(new Intent(context, AdvancedShortcutActivity.class)
                            .setAction("ACTION"))
                    .getIntents())
            .setRank(1)
            .build());
    return Arrays.asList(enabledShortcuts, disabledShortcuts);
}
 
開發者ID:MatthiasRobbers,項目名稱:shortbread,代碼行數:27,代碼來源:TwoShortcutActivitiesGenerated.java

示例10: createShortcuts

import android.graphics.drawable.Icon; //導入依賴的package包/類
public static List<List<ShortcutInfo>> createShortcuts(Context context) {
    List<ShortcutInfo> enabledShortcuts = new ArrayList<>();
    List<ShortcutInfo> disabledShortcuts = new ArrayList<>();
    enabledShortcuts.add(new ShortcutInfo.Builder(context, "ID_2")
            .setShortLabel("SHORT_LABEL")
            .setLongLabel("LONG_LABEL")
            .setIcon(Icon.createWithResource(context, 123))
            .setDisabledMessage("DISABLED_MESSAGE")
            .setIntents(TaskStackBuilder.create(context)
                    .addParentStack(AdvancedShortcutActivity.class)
                    .addNextIntent(new Intent(context, AdvancedShortcutActivity.class)
                            .setAction("ACTION"))
                    .getIntents())
            .setRank(1)
            .build());
    return Arrays.asList(enabledShortcuts, disabledShortcuts);
}
 
開發者ID:MatthiasRobbers,項目名稱:shortbread,代碼行數:18,代碼來源:AdvancedShortcutActivityGenerated.java

示例11: addChoiceShortcuts

import android.graphics.drawable.Icon; //導入依賴的package包/類
private void addChoiceShortcuts() {
    ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
    if (mChoice.isFinish()) {
        shortcutManager.removeAllDynamicShortcuts();
        return;
    }
    if (mChoice.choices == null || mChoice.choices.size() == 0) {
        return;
    }
    List<ShortcutInfo> choiceShortcuts = new ArrayList<>();
    int rank = 1;
    for (Choice choice : mChoice.choices) {
        ShortcutInfo choiceShortcut = new ShortcutInfo.Builder(this, IdUtil.getRandomUniqueShortcutId())
                .setShortLabel(choice.action)
                .setLongLabel(choice.action)
                .setDisabledMessage(getString(R.string.shortcut_disabled_message))
                .setIcon(Icon.createWithBitmap(choice.getActionEmoji(this)))
                .setIntent(IntentUtil.choice(this, choice))
                .setRank(rank)
                .build();
        choiceShortcuts.add(choiceShortcut);
        rank++;
    }
    shortcutManager.setDynamicShortcuts(choiceShortcuts);
}
 
開發者ID:nicholasrout,項目名稱:shortstories,代碼行數:26,代碼來源:ChoiceActivity.java

示例12: createNotify

import android.graphics.drawable.Icon; //導入依賴的package包/類
private void createNotify(){
    Intent resultIntent = new Intent(this, MainActivity.class);
    resultIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    PendingIntent piShot = PendingIntent.getService(this, 0, shotIntent, PendingIntent.FLAG_CANCEL_CURRENT);
    Icon icon = Icon.createWithResource(this, R.drawable.ic_camera);
    Notification.Action shotAction = new Notification.Action.Builder(icon, getString(R.string.notify_title_shot), piShot).build();

    NotifyUtil.notifyShot(this, resultIntent, 1, shotAction);
}
 
開發者ID:NicoToast,項目名稱:ScreenShotAnywhere,代碼行數:11,代碼來源:MainActivity.java

示例13: onGetChooserTargets

import android.graphics.drawable.Icon; //導入依賴的package包/類
@Override
public List<ChooserTarget> onGetChooserTargets(ComponentName targetComponentName,
                                               IntentFilter intentFilter) {
    if (sServer != null && sChannel != null) {
        if (System.currentTimeMillis() - sSetTime >= SET_TIMEOUT) {
            sServer = null;
            sChannel = null;
            return null;
        }
        ComponentName componentName = new ComponentName(getPackageName(),
                MainActivity.class.getCanonicalName());

        List<ChooserTarget> targets = new ArrayList<>();
        Bundle extras = new Bundle();
        extras.putString(MainActivity.ARG_SERVER_UUID, sServer.toString());
        extras.putString(MainActivity.ARG_CHANNEL_NAME, sChannel);
        targets.add(new ChooserTarget(sChannel,
                Icon.createWithResource(this, R.drawable.ic_direct_share),
                1.f, componentName, extras));
        return targets;
    }
    return null;
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:24,代碼來源:IRCChooserTargetService.java

示例14: getShortcut

import android.graphics.drawable.Icon; //導入依賴的package包/類
/**
     * 構造App Shortcut Intent
     *
     * @param appInfo
     * @return
     */
    private ShortcutInfo getShortcut(AppInfo appInfo) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
            ShortcutInfo shortcut = new ShortcutInfo.Builder(mContext, appInfo.getAppPackageName())
                    .setShortLabel(appInfo.getAppName())
                    .setIcon(Icon.createWithBitmap(appInfo.getAppIcon()))
                    .setIntent(
                            new Intent(ShortcutActivity.OPEN_APP_SHORTCUT)
                                    .putExtra(ShortcutActivity.EXTRA_PACKAGE_NAME, appInfo.getAppPackageName())
                            // this dynamic shortcut set up a back stack using Intents, when pressing back, will go to MainActivity
                            // the last Intent is what the shortcut really opened
//                            new Intent[]{
//                                    new Intent(Intent.ACTION_MAIN, Uri.EMPTY, mContext, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK),
//                                    new Intent(AppListActivity.ACTION_OPEN_DYNAMIC)
//                                    // intent's action must be set
//                            }
                    )
                    .build();

            return shortcut;
        } else {
            return null;
        }
    }
 
開發者ID:XYScience,項目名稱:StopApp,代碼行數:30,代碼來源:ShortcutsManager.java

示例15: getColoredDrawable

import android.graphics.drawable.Icon; //導入依賴的package包/類
private static Drawable getColoredDrawable(Context ctx, String pkg, Icon icon) {
    if (icon == null) return null;

    Drawable d = null;
    if (pkg == null || PACKAGE_NAME.equals(pkg)) {
        final int iconId = (int) XposedHelpers.callMethod(icon, "getResId");
        d = SysUiManagers.IconManager.getBasicIcon(iconId);
        if (d != null) {
            return d;
        }
    }
    d = icon.loadDrawable(ctx);
    if (d != null) {
        if (SysUiManagers.IconManager.isColoringEnabled()) {
            d = SysUiManagers.IconManager.applyColorFilter(d.mutate(),
                    PorterDuff.Mode.SRC_IN);
        } else {
            d.clearColorFilter();
        }
    }
    return d;
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:23,代碼來源:ModStatusbarColor.java


注:本文中的android.graphics.drawable.Icon類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。