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


Java ShortcutManager.removeAllDynamicShortcuts方法代碼示例

本文整理匯總了Java中android.content.pm.ShortcutManager.removeAllDynamicShortcuts方法的典型用法代碼示例。如果您正苦於以下問題:Java ShortcutManager.removeAllDynamicShortcuts方法的具體用法?Java ShortcutManager.removeAllDynamicShortcuts怎麽用?Java ShortcutManager.removeAllDynamicShortcuts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.pm.ShortcutManager的用法示例。


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

示例1: addChoiceShortcuts

import android.content.pm.ShortcutManager; //導入方法依賴的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

示例2: setShortcut

import android.content.pm.ShortcutManager; //導入方法依賴的package包/類
@Override
public void setShortcut(String did, String manufacturer, String deviceName) {
    //Home screen shortcut for favourite device

    if (Build.VERSION.SDK_INT < 25)
        return;
    ShortcutManager sM = getSystemService(ShortcutManager.class);
    sM.removeAllDynamicShortcuts();

    Intent intent = new Intent(getApplicationContext(), MainActivity.class);
    intent.setAction(Intent.ACTION_VIEW);
    intent.putExtra(Constants.EXTRA_DEVICE_ID, did);

    ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "shortcut1")
            .setIntent(intent)
            .setLongLabel(manufacturer + " " + deviceName)
            .setShortLabel(deviceName)
            .setIcon(Icon.createWithResource(this, R.drawable.ic_device_placeholder))
            .build();
    sM.setDynamicShortcuts(Collections.singletonList(shortcut));
}
 
開發者ID:out386,項目名稱:AndroidFileHost_Browser,代碼行數:22,代碼來源:MainActivity.java

示例3: updateShortcuts

import android.content.pm.ShortcutManager; //導入方法依賴的package包/類
public static void updateShortcuts(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
            shortcutManager.removeAllDynamicShortcuts();
            List<PreferredJourney> l;
        if ((l = PreferredStationsPreferences.getAllPreferredJourneys(context)).size() > 0) {
                shortcutManager.addDynamicShortcuts(setShortcuts(context, l.get(0)));
            }
    }
}
 
開發者ID:albertogiunta,項目名稱:justintrain-client-android,代碼行數:11,代碼來源:ShortcutHelper.java

示例4: onCreate

import android.content.pm.ShortcutManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

    ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);

    shortcutManager.removeAllDynamicShortcuts();
    int newWallId = ShortcutsUtils.getNextRailNumber(shortcutManager);
    ShortcutInfo ballShortcut = ShortcutsUtils.createTrainShortcut(this);
    ShortcutInfo wallShortcut = ShortcutsUtils.createRailShortcut(this, newWallId);
    shortcutManager.setDynamicShortcuts(Arrays.asList(ballShortcut, wallShortcut));

    setContentView(R.layout.activity_main);

    rootView = findViewById(R.id.activity_main_root);

    viewPager = (ViewPager) findViewById(R.id.activity_main_view_pager);
    pagerAdapter = new TutorialViewPagerAdapter(getFragmentManager());
    viewPager.setAdapter(pagerAdapter);
    rootView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finishActivity();
        }
    });
}
 
開發者ID:nirhart,項目名稱:shortrain,代碼行數:28,代碼來源:MainActivity.java

示例5: removeAllShortcuts

import android.content.pm.ShortcutManager; //導入方法依賴的package包/類
private void removeAllShortcuts() {
    ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
    shortcutManager.removeAllDynamicShortcuts();
}
 
開發者ID:nicholasrout,項目名稱:shortstories,代碼行數:5,代碼來源:QuitStoryActivity.java

示例6: updateDynamicShortcuts

import android.content.pm.ShortcutManager; //導入方法依賴的package包/類
private void updateDynamicShortcuts() {
    ShortcutManager shortcutManager;

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {

        Intent intentGenerateQrCode = new Intent(this, MainActivity.class);
        intentGenerateQrCode.setFlags((Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
        intentGenerateQrCode.setAction(Constants.ACTION_GENERATE_QR_CODE);

        ShortcutInfo shortcutGenerateQrCode = new ShortcutInfo.Builder(this, SHORTCUT_ID_GENERATE_QR_CODE)
                .setShortLabel(getString(R.string.shortcut_generate_qr_code))
                .setLongLabel(getString(R.string.shortcut_generate_qr_code))
                .setIcon(Icon.createWithResource(this, R.drawable.ic_shortcut_qr))
                .setIntent(intentGenerateQrCode)
                .build();

        Intent intentTransferIotas = new Intent(this, MainActivity.class);
        intentTransferIotas.setFlags((Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));
        intentTransferIotas.setAction(Constants.ACTION_SEND_TRANSFER);

        ShortcutInfo shortcutTransferIotas = new ShortcutInfo.Builder(this, SHORTCUT_ID_SEND_TRANSFER)
                .setShortLabel(getString(R.string.shortcut_send_transfer))
                .setLongLabel(getString(R.string.shortcut_send_transfer))
                .setIcon(Icon.createWithResource(this, R.drawable.ic_shortcut_transaction))
                .setIntent(intentTransferIotas)
                .build();

        shortcutManager = getSystemService(ShortcutManager.class);

        if (shortcutManager != null) {
            if (IOTA.seed != null) {
                shortcutManager.setDynamicShortcuts(Arrays.asList(shortcutGenerateQrCode, shortcutTransferIotas));
                shortcutManager.enableShortcuts(Arrays.asList(SHORTCUT_ID_GENERATE_QR_CODE, SHORTCUT_ID_SEND_TRANSFER));
            } else {
                // remove shortcuts if Iota.seed.isEmpty()
                shortcutManager.disableShortcuts(Arrays.asList(SHORTCUT_ID_GENERATE_QR_CODE, SHORTCUT_ID_SEND_TRANSFER));
                shortcutManager.removeAllDynamicShortcuts();
            }
        }
    }
}
 
開發者ID:iotaledger,項目名稱:android-wallet-app,代碼行數:42,代碼來源:MainActivity.java

示例7: removeAllShortcuts

import android.content.pm.ShortcutManager; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
public static void removeAllShortcuts(Context context) {
    ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
    shortcutManager.disableShortcuts(Arrays.asList(ApplicationConstants.SEARCH_SHORTCUT_ID));
    shortcutManager.removeAllDynamicShortcuts();
}
 
開發者ID:ZinoKader,項目名稱:SpotiQ,代碼行數:7,代碼來源:ShortcutUtil.java

示例8: setShortcuts

import android.content.pm.ShortcutManager; //導入方法依賴的package包/類
private void setShortcuts() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return;

    PriorityQueue<Class<? extends Fragment>> queue = new PriorityQueue<>(
            new Comparator<Class<? extends Fragment>>() {
                @Override
                public int compare(Class<? extends Fragment> o1, Class<? extends Fragment> o2) {
                    int opened1 = Prefs.getInt(o1.getSimpleName() + "_opened",
                            0, NavigationActivity.this);
                    int opened2 = Prefs.getInt(o2.getSimpleName() + "_opened",
                            0, NavigationActivity.this);
                    return opened2 - opened1;
                }
            });

    for (Map.Entry<Integer, Class<? extends Fragment>> entry : mActualFragments.entrySet()) {
        Class<? extends Fragment> fragmentClass = entry.getValue();
        if (fragmentClass == null || fragmentClass == SettingsFragment.class) continue;

        queue.offer(fragmentClass);
    }

    List<ShortcutInfo> shortcutInfos = new ArrayList<>();
    ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
    shortcutManager.removeAllDynamicShortcuts();
    for (int i = 0; i < 4; i++) {
        NavigationFragment fragment = findNavigationFragmentByClass(queue.poll());
        Intent intent = new Intent(this, MainActivity.class);
        intent.setAction(Intent.ACTION_VIEW);
        intent.putExtra("section", fragment.mFragmentClass.getCanonicalName());
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

        ShortcutInfo shortcut = new ShortcutInfo.Builder(this,
                fragment.mFragmentClass.getSimpleName())
                .setShortLabel(getString(fragment.mId))
                .setLongLabel(Utils.strFormat(getString(R.string.open), getString(fragment.mId)))
                .setIcon(Icon.createWithResource(this, fragment.mDrawable == 0 ?
                        R.drawable.ic_blank : fragment.mDrawable))
                .setIntent(intent)
                .build();
        shortcutInfos.add(shortcut);
    }
    shortcutManager.setDynamicShortcuts(shortcutInfos);
}
 
開發者ID:Grarak,項目名稱:KernelAdiutor,代碼行數:45,代碼來源:NavigationActivity.java


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