7

The values are getting passed and execution happens properly but i see these being thrown in logcat and i want to eliminate these , i checked the older forums but nothing in specific .I am posting my code below , please do let me know why would this problem occur

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

Exception which is being thrown repeatedly is : but this does not hinder the execution

: 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)
Ravi Rode
  • 23
  • 5
Kavitha
  • 461
  • 2
  • 8
  • 22
  • Did you manage to find a solution without using serialisation? – bencallis Jun 01 '13 at 01:54
  • possible duplicate of ["BadParcelableException: ClassNotFoundException when unmarshalling " while using Parcel.read method that has a ClassLoader as argument](http://stackoverflow.com/questions/18126249/badparcelableexception-classnotfoundexception-when-unmarshalling-myclass-wh) – Flow Aug 30 '14 at 13:15

2 Answers2

4

I think this is answered for you here: Problem unmarshalling parcelables.

Basically you need to set the class loader because the AlarmManagerService is a separate OS process.

Community
  • 1
  • 1
Jason
  • 1,086
  • 5
  • 10
  • U mean , this line is the one which throws error source.readList(pollingIntervalArray, Integer.class.getClassLoader()); I don not see any other place where class loader is passed or needs to be passed ??? – Kavitha Jul 28 '11 at 22:53
  • No. You're not even getting to that line of the ClassNotFoundException (in the stack trace you've provided). You're not alone in trying to send a parcelable through a PendingIntent: http://stackoverflow.com/questions/2307476/classnotfoundexception-when-using-custom-parcelable/2307764#2307764 – Jason Jul 29 '11 at 13:41
  • Oops... hit return too soon. The problem is the AlarmManager isn't using your class loader to deserialize the PendingIntent so it doesn't have access to your ExecutionInfo class. Unfortunately, it looks as though you may have to use an alternate serialization method. One possibility would be to create a Parcel yourself (`Parcel parcel = Parcel.obtain()`), serialize it (`infoObject.writeToParcel(parcel, 0)`), get the byte array (`byte[] rawParcel = parcel.marshall()`) and put that byte array in your bundle. On the other side you'd have to use Parcel.unmarshall() and then use the constructor – Jason Jul 29 '11 at 13:51
  • Yeah i guess i need to do it myself , actually the values get passed and it works fine but the exception don look good , i want to remove them , do you know any link i can use where they show how to do it manually ??? Thanks – Kavitha Aug 01 '11 at 20:54
-7

Ok finally i am using serialization so that i do not get this exception . I serialize the object convert to byte array store it and then pass it in PendingIntent check.

I am sure this increases the over head but does not seem to affect the working .In this case when alarms get triggered i do not see any exception

Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158
Kavitha
  • 461
  • 2
  • 8
  • 22