我已经阅读过某处(但我无法再找到它),应该可以在设备主屏幕上从快捷方式发送附加内容。我成功创建了一个快捷方式,但Bundle extras = getIntent().getExtras();
给出了一个空指针。快捷方式主屏幕,如何发送演示文稿
我创建快捷方式如下:
Intent shortcutIntent = new Intent(this.getApplicationContext(),
Shortcut_Activity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent();
addIntent
.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(this.getApplicationContext(),
R.drawable.ic_shortcut));
addIntent.putExtra("ID", id); //THIS IS THE EXTRA DATA I WANT TO ATTACH
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
this.getApplicationContext().sendBroadcast(addIntent);
这可能吗?如果呢,如何?
但是这个代码将崩溃,如果捆绑,这里命名临时演员(无论何种原因)是空还是 – JacksOnF1re 2014-12-05 16:09:56
以防万一你还有空例外,**删除旧的快捷方式**,让新的创建如果你使用'addIntent.putExtra(“duplicate”,false);' – Choletski 2017-08-31 13:30:00