2011-07-28 6 views
7

値が渡されて実行が適切に行われますが、これらがlogcatにスローされているのを見て、これらを排除したいと思っています。これは、実行android.os.BadParcelableException:アンマーシャリング時のClassNotFoundException例外:

: 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

が表示されていないこの場合.IN作業に影響を与えるようには見えませんが、シリアライズを使用せずに解決策を見つけるために管理していましたか? – bencallis

+0

ClassLoaderを引数として持つParcel.readメソッドを使用しているときに["BadParcelableException:ClassNotFoundExceptionをアンマーシャリングするときに"の複製が可能です](http://stackoverflow.com/questions/18126249/badparcelableexception-classnotfoundexception-when-unmarshalling-myclass-wh ) – Flow

答えて

-7

最後に私はserializationを使用していますので、この例外は発生しません。私はバイト配列に変換するオブジェクトをシリアル化し、それをPendingIntentチェックで渡します。

私は、これはオーバーヘッドが増加確信していますが、アラームがトリガされ得るとき、私はすべての例外

+1

非常に便利な解決法ではありません。なぜなら、あなたは単に 'Parcelable'を使ってスキップして代わりに' Serializable'を使うことができるからです。 – Melllvar

+1

あなたは回避策に頼るべきではなく、より効果的な解決策を見つけるべきです。 – Varundroid

4

を妨げない、私はこれがために答えていると思う:以下の私のコードを掲載、この問題が繰り返しスローされ

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

例外はあるが発生する理由私に教えてくださいあなたはここにいます:Problem unmarshalling parcelables

基本的に、AlarmManagerServiceは別のOSプロセスであるため、クラスローダーを設定する必要があります。

+0

これは、エラーをスローする行です。source.readList(pollingIntervalArray、Integer.class.getClassLoader());私はクラスローダーが渡されるか、渡される必要がある他の場所を見ませんか? – Kavitha

+0

いいえ、あなたはClassNotFoundExceptionの行に到達していません(あなたが提供したスタックトレース内)。あなたはPendingIntentを介してパーセルブルを送信しようとしているだけではありません:http://stackoverflow.com/questions/2307476/classnotfoundexception-when-using-custom-parcelable/2307764#2307764 – Jason

+0

おっと...ヒットリターンが早すぎます。問題は、AlarmManagerがクラスローダーを使用してPendingIntentを逆シリアル化していないため、ExecutionInfoクラスにアクセスできないことです。残念ながら、別のシリアル化メソッドを使用する必要があるように見えます。 (Parcel parcel = Parcel.obtain())、シリアル化( 'infoObject.writeToParcel(parcel、0)')、バイト配列( 'byte [] rawParcel = parcel)を得ることができます。 marshall() ')、バイト配列をバンドルに入れます。反対側では、Parcel.unmarshall()を使用してコンストラクタを使用する必要があります – Jason

関連する問題