当前位置: 首页>>代码示例>>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;未经允许,请勿转载。