2010-10-06 47 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,然後傳遞到芯。 不完美的解決方案,但它現在工作。

相關問題