2010-10-06 85 views
0

我想在实现Parcelable的自定义类型的额外数据内发送带有意图的广播消息。传递给核心的自定义可分类对象

在更多的细节:我想在HS 但是系统不接受我的自定义命令类型的对象创建一个快捷方式,错误消息:android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.solvek.ussdfaster.entities.Command 当用户点击该快捷方式此对象将被传递回我的应用程序。

Intent shortcutIntent = new Intent(this, FormActivity.class); 
    shortcutIntent.putExtra("command", command); // Note - commmand is my custom object 
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 

    Intent intent = new Intent(); 
    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); 
    intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, command.getTitle()); 
    Parcelable iconResource = Intent 
     .ShortcutIconResource 
     .fromContext(this, R.drawable.ic_launcher); 
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); 
    intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); 

    sendBroadcast(intent); 

回答

0

对于命令I类实现XML序列化(使用XStream的)和序列化命令对象到字符串为XML,然后传递到芯。 不完美的解决方案,但它现在工作。