【问题标题】:Shortcut intent extras lost after restart?重启后快捷方式意图附加功能丢失?
【发布时间】: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,我检查了日志并进行了调试)。这是正常行为吗?我做错了吗?我需要将额外内容传递给活动。

【问题讨论】:

标签: android null shortcut reboot extras


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-05
    • 1970-01-01
    相关资源
    最近更新 更多