我的Android 7.1.1新快捷方式存在一些问题。Android动态快捷方式图标
第二个drawable没有资源ID。这里是图片和代码片段。
private void createShortcuts(String deviceValue, String tablequery, int pos, String devImage, int index) {
ShortcutManager shortcutManager = mActivity.getSystemService(ShortcutManager.class);
if (index == 0) {
List<ShortcutInfo> scInfo = shortcutManager.getDynamicShortcuts();
Bundle b = new Bundle();
b.putInt("position", pos);
b.putString("table", tablequery);
b.putString("device", devImage);
String add = deviceValue + "_" + tablequery;
ShortcutInfo shortcut = new ShortcutInfo.Builder(mActivity, add)
.setShortLabel(deviceValue) // Shortcut Icon tab
.setLongLabel(deviceValue) // Displayed When Long Pressing On App Icon
.setIcon(Icon.createWithResource(mActivity, R.drawable.ic_shortcut_phone))
.setIntents(new Intent[]{
new Intent(Intent.ACTION_MAIN, Uri.EMPTY, mActivity, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK),
new Intent(Intent.ACTION_DEFAULT, Uri.EMPTY, mActivity, Device_Detail_Activity.class).putExtras(b)
})
.build();
scInfo.add(shortcut);
shortcutManager.setDynamicShortcuts(scInfo);
} else if (index == 1) {
String remove = deviceValue + "_" + tablequery;
shortcutManager.removeDynamicShortcuts(Arrays.asList(remove));
}
}
我在做什么错?
您在有三个应用程序的快捷方式屏幕截图。您的代码被硬连线以始终使用相同的资源。所以,你的第一个和第三个应用程序快捷方式应该有相同的图标......但他们不这样做,更不用说第二个问题了。如果您一直在更改您的应用程序,并且您拥有出色的动态应用程序快捷方式,则可能需要卸载并重新安装应用程序,或者强制您的代码重新构建所有这些动态应用程序快捷方式,然后查看是否有帮助。 – CommonsWare
Nope已经尝试我有2动态和一个静态快捷方式 –