【发布时间】:2011-05-04 17:48:37
【问题描述】:
我的应用程序监听 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,我检查了日志并进行了调试)。这是正常行为吗?我做错了吗?我需要将额外内容传递给活动。
【问题讨论】:
-
好的,我正在回答我自己的问题。我将一个字符串数组放入额外的意图中。主屏幕不会保留字符串数组!我找到了答案:groups.google.com/group/android-developers/browse_thread/thread/…
-
可以,但我必须等 8 小时才能回答我自己的问题。
标签: android null shortcut reboot extras