3

我的应用程序侦听 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,我检查了日志并进行了调试)。这是正常行为吗?我做错了吗?我需要将额外内容传递给活动。

4

1 回答 1

1

我正在回答我自己的问题。我将一个字符串数组放入额外的意图中。主屏幕不会保留字符串数组!

我在以下位置找到了答案: http ://groups.google.com/group/android-developers/browse_thread/thread/7f2ce458bd5d112f/189e2b7b2b2532d7

于 2011-05-05T07:29:47.037 回答