阅读191 返回首页    go 微软 go Office


小米手机通过Broadcast无法添加快捷方式

 public void createShortCut() {

       // boolean exist = hasShortcut();

        // 安装的Intent

        Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");

        // 快捷名称

        shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.name));

        // 快捷图标是否允许重复

        shortcut.putExtra("duplicate", false);


        Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);

        shortcutIntent.putExtra("open", 1);//可以不传

        shortcutIntent.setClassName(getPackageName(), "com.test.brc.ui.TestActivity");

        shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

        shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);


        // 快捷图片

        Parcelable icon = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon);

        shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);

        // 发送广播

        sendBroadcast(shortcut);

    }


请问小米手机为何无法添加快捷方式到桌面?而华为、三星都可以。如何解决呢


public void createShortCut() { // boolean exist = hasShortcut(); // 安装的Intent Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); // 快捷名称 shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.name)); // 快捷图标是否允许重复 shortcut.putExtra("duplicate", false); Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.putExtra("open", 1);//可以不传 shortcutIntent.setClassName(getPackageName(), "com.hxdsw.brc.ui.AppStart");//com.hxdsw.brc.ui.AppStart shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); // 快捷图片 Parcelable icon = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon); shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon); // 发送广播 sendBroadcast(shortcut); }

最后更新:2017-10-11 18:03:57

  上一篇:go 小米note图片浏览设置的自动旋转,可是实际操作不能自动旋转
  下一篇:go 亲们 有ZUK edge 的miui适配的系统吗