2011-07-28 15 views
7

Değerler geçiyor ve yürütme düzgün bir şekilde gerçekleşiyor ancak bunların logcat'e atıldığını görüyorum ve bunları ortadan kaldırmak istiyorum, eski forumları kontrol ettim ancak belirli bir şey yok. aşağıda benim kod gönderme, beni bu sorun defalarca atılmış olduğunu ediliyorandroid.os.BadParcelableException: unmarshalling olduğunda ClassNotFoundException: istisna

public class ExecutionInfo implements Parcelable 
{ 

    private int offSet; 

    private List<Integer> pollingIntervalArray = new ArrayList<Integer>(); 

    private List<String> commandLst= new ArrayList<String>(); 

    private int repeatCount; 

    private int executorId; 

    private int processType; 


    public ExecutionInfo() 
    { 

    } 

    public ExecutionInfo(Parcel source) 
    { 
     offSet = source.readInt(); 
     repeatCount = source.readInt(); 
     executorId = source.readInt(); 
     processType = source.readInt(); 
     source.readStringList(commandLst); 
     source.readList(pollingIntervalArray, Integer.class.getClassLoader()); 
    } 

    public int getOffSet() 
    { 
     return offSet; 
    } 

    public void setOffSet(int offSet) 
    { 
     this.offSet = offSet; 
    } 

    public List<Integer> getInterval() 
    { 
     return pollingIntervalArray; 
    } 

    public void setInterval(List<Integer> pollingIntervalVec) 
    { 
     this.pollingIntervalArray = pollingIntervalVec; 
    } 

    public List<String> getCommandLst() 
    { 
     return commandLst; 
    } 

    public void setCommands(String command) 
    { 
     commandLst.add(command); 
    } 

    public int getRepeatCount() 
    { 
     return repeatCount; 
    } 

    public void setRepeatCount(int repeatCount) 
    { 
     this.repeatCount = repeatCount; 
    } 

    public int getExecutorId() 
    { 
     return executorId; 
    } 

    public void setExecutorId(int executorId) 
    { 
     this.executorId = executorId; 
    } 

    @Override 
    public int describeContents() 
    { 
     // TODO Auto-generated method stub 
     return 0; 
    } 

    @Override 
    public void writeToParcel(Parcel dest, int flags) 
    { 

      dest.writeInt(offSet); 
      dest.writeInt(repeatCount); 
      dest.writeInt(executorId); 
      dest.writeInt(processType); 
      dest.writeStringList(commandLst); 
      dest.writeList(pollingIntervalArray); 
    } 

    public static final Parcelable.Creator<ExecutionInfo> CREATOR = new Parcelable.Creator<ExecutionInfo>() 
    { 
     public ExecutionInfo createFromParcel(Parcel in) 
     { 
      return new ExecutionInfo(in); 
     } 

     public ExecutionInfo[] newArray(int size) 
     { 
      return new ExecutionInfo[size]; 
     } 
    }; 

    public int getProcessType() 
    { 
     return processType; 
    } 

    public void setProcessType(int processType) 
    { 
     this.processType = processType; 
    } 
} 

İstisna oluşacak nedenini bildirin lütfen: ama bu bunun için cevap olduğunu düşünüyorum yürütme

: com.seven.superapptwitter.xmlHandler.ExecutionInfo 
07-27 16:52:11.418: WARN/Intent(2458): Failure filling in extras 
07-27 16:52:11.418: WARN/Intent(2458): android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.seven.superapptwitter.xmlHandler.ExecutionInfo 
07-27 16:52:11.418: WARN/Intent(2458):  at android.os.Parcel.readParcelable(Parcel.java:1883) 
07-27 16:52:11.418: WARN/Intent(2458):  at android.os.Parcel.readValue(Parcel.java:1771) 
07-27 16:52:11.418: WARN/Intent(2458):  at android.os.Parcel.readMapInternal(Parcel.java:2008) 
07-27 16:52:11.418: WARN/Intent(2458):  at android.os.Bundle.unparcel(Bundle.java:208) 
07-27 16:52:11.418: WARN/Intent(2458):  at android.os.Bundle.putAll(Bundle.java:281) 
07-27 16:52:11.418: WARN/Intent(2458):  at android.content.Intent.fillIn(Intent.java:5127) 
07-27 16:52:11.418: WARN/Intent(2458):  at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:195) 
07-27 16:52:11.418: WARN/Intent(2458):  at com.android.server.am.PendingIntentRecord.send(PendingIntentRecord.java:177) 
07-27 16:52:11.418: WARN/Intent(2458):  at android.app.PendingIntent.send(PendingIntent.java:400) 
07-27 16:52:11.418: WARN/Intent(2458):  at com.android.server.AlarmManagerService$AlarmThread.run(AlarmManagerService.java:680) 
+0

Eğer seri kullanmadan bir çözüm bulmak için yönetmek mi herhangi istisna görmüyorum tetiklenen olsun çekmez.Bu durumda çalışmasını etkileyebilecek görünmüyor eminim? – bencallis

+0

olası bir argüman olarak bir ClassLoader olan Parcel.read yöntemi kullanırken unmarshalling ne zaman ["BadParcelableException: ClassNotFoundException" olası kopyası (http://stackoverflow.com/questions/18126249/badparcelableexception-classnotfoundexception-when-unmarshalling-myclass-wh – Flow

cevap

-7

Sonunda bu istisnayı alamam için serialization kullanıyorum. Nesneyi serileştirerek bayt dizisine dönüştürün ve PendingIntent denetiminde iletin.

ben bunun üzerinde kafa artırır ancak alarmlar ı

+1

Çok kullanışlı bir çözüm değil, çünkü 'Parcelable' kullanarak atlayabilir ve bunun yerine' Serializable' kullanabilirsiniz. – Melllvar

+1

Daha iyi çalışan bir çözüm bulmak yerine iş çevrelerine güvenmemelisiniz. – Varundroid

4

engellemeyen burdasınız: Problem unmarshalling parcelables.

Temelde, sınıf yükleyiciyi ayarlamanız gerekir çünkü AlarmManagerService ayrı bir işletim sistemidir.

+0

U, bu satır hata kaynağı atar.readList (pollingIntervalArray, Integer.class.getClassLoader()); Sınıf yükleyicisinin geçtiği veya geçilmesi gereken başka bir yer görmüyorum ??? – Kavitha

+0

Hayır. ClassNotFoundException (hatta sağladığınız yığın izlemede) satırına bile girmiyorsunuz. Bir PendingIntent aracılığıyla bir parceble göndermeye çalışırken yalnız değilsiniz: http://stackoverflow.com/questions/2307476/classnotfoundexception-when-using-custom-parcelable/2307764#2307764 – Jason

+0

Oops ... geri dönüş çok erken. Sorun, AlarmManager'ın sınıf yükleyicinizi PendingIntent'i seri hale getirmek için kullanmamasıdır, böylece ExecutionInfo sınıfınıza erişiminiz yoktur. Ne yazık ki, alternatif bir serileştirme yöntemi kullanmak zorunda kalabilirsiniz. Bir olasılık kendiniz yaratmak (Parcel parsel = Parcel.obtain() '), serileştirmek (' infoObject.writeToParcel (parcel, 0) '), byte dizisini (byte [] rawParcel = parsel) elde etmek olacaktır. marshall() ') ve bu bayt dizisini paketinize koyun. Diğer tarafta Parcel.unmarshall() kullanmanız ve sonra kurucuyu kullanmanız gerekiyor. – Jason