Question

My application listens to the android.intent.action.CREATE_SHORTCUT broadcast, in my code I am creating a shortcut which includes a String extra like this:

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);

The shortcut works BUT the extras are lost on each phone reboot (they return null, I checked logs and debugged). Is this normal behaviour? I am doing it wrong? I need to pass the extras to the activity.

Was it helpful?

Solution

I am answering my own question. I was placing a String array into the intent extra. Home screen will not persist string arrays!

I found the answer at: http://groups.google.com/group/android-developers/browse_thread/thread/7f2ce458bd5d112f/189e2b7b2b2532d7

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top