7

这些值正在传递并且执行正确,但我看到这些被抛出在 logcat 中,我想消除这些,我检查了较旧的论坛,但没有具体说明。我在下面发布我的代码,请让我知道为什么会出现这个问题发生

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

重复抛出的异常是:但这并不妨碍执行

: 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)
4

2 回答 2

4

我认为这是为您解答的问题:Problem unmarshalling parcelables

基本上您需要设置类加载器,因为 AlarmManagerService 是一个单独的操作系统进程。

于 2011-07-28T21:48:59.700 回答
-7

好的,最后我正在使用序列化,这样我就不会得到这个异常。我将对象序列化为字节数组存储它,然后将其传递给 PendingIntent 检查。

我确信这会增加开销,但似乎不会影响工作。在这种情况下,当警报被触发时,我没有看到任何异常

于 2011-08-01T22:21:52.863 回答