我的应用程序侦听 android.intent.action.CREATE_SHORTCUT 广播,在我的代码中,我正在创建一个快捷方式,其中包含一个额外的字符串,如下所示:
Intent shortcutIntent = new Intent(Intent.ACTION_VIEW);
shortcutIntent.setClassName("com.some.name","com.some.name.Activity");
shortcutIntent.putExtra("stringid", "some string value");
ShortcutIconResource iconResource = Intent.ShortcutIconResource.fromContext(ShortcutActivity.this,iconIdentifier);
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, channelName);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
setResult(RESULT_OK, intent);
该快捷方式有效,但每次手机重新启动时都会丢失额外的内容(它们返回 null,我检查了日志并进行了调试)。这是正常行为吗?我做错了吗?我需要将额外内容传递给活动。