1

I am having problems with Activity Recognition and I get the following error:

05-07 22:32:03.553: E/AndroidRuntime(5546): FATAL EXCEPTION: IntentService[dk.finne.minrute.service.ActivityRecognitionIntentService]
05-07 22:32:03.553: E/AndroidRuntime(5546): Process: dk.finne.minrute, PID: 5546
05-07 22:32:03.553: E/AndroidRuntime(5546): android.os.BadParcelableException: Parcelable protocol requires a Parcelable.Creator object called  CREATOR on class com.google.android.gms.location.ActivityRecognitionResult
05-07 22:32:03.553: E/AndroidRuntime(5546):     at android.os.Parcel.readParcelableCreator(Parcel.java:2156)

The ActivityRecognitionResult class is from Google Play Services, so how can I fix this error?

GoRoS
  • 5,183
  • 2
  • 43
  • 66
Kasper Finne Nielsen
  • 2,086
  • 2
  • 17
  • 28
  • Maybe you use proguard and you have the same problem as here : http://stackoverflow.com/questions/18610232/proguard-causes-a-crash-in-google-play-services-activityrecognitionresult-getmo – Piotr May 09 '14 at 20:42

1 Answers1

0

This is a working example except for passing the activity (Still haven't figured that out). Basically you don't have the CREATOR thingie. Next time if you include a code sample it would help out.

import android.app.Activity;

import android.os.Parcel;
import android.os.Parcelable;

public class QueryParcible implements Parcelable{
private long fromBtn,toBtn;
private Boolean gpsB, picB;
Activity activity;

public QueryParcible() {}
public QueryParcible(Parcel parcel) {}

    public static final Parcelable.Creator<QueryParcible> CREATOR =
               new Parcelable.Creator<QueryParcible>(){

                @Override
      public QueryParcible createFromParcel(Parcel source)     {
                 return new QueryParcible(source);
                }

                @Override
                public QueryParcible[] newArray(int size) {
                 return new QueryParcible[size];
                }
             };
             @Override
             public int describeContents() {
              return 0;
             }

             @Override
             public void writeToParcel(Parcel dest, int flags) {
                 dest.writeSerializable(fromBtn);
                 dest.writeSerializable(toBtn);              
                 dest.writeInt(gpsB?1:0);
                 dest.writeInt(picB?1:0);   
                 dest.writeValue(activity);
             }  
            public void readFromParcel(Parcel source){
                 fromBtn= source.readLong();
                 toBtn= source.readLong();               
                 gpsB=source.readInt()==1;
                 picB=source.readInt()==1;
                // activity=source.readValue(activity);
             }

             public Boolean getGpsB() {
                return gpsB;
            }
            public void setGpsB(Boolean gpsB) {
                this.gpsB = gpsB;
            }
            public Boolean getPicB() {
                return picB;
            }
            public void setPicB(Boolean picB) {
                this.picB = picB;
                }
public long getFromBtn() {
    return fromBtn;
}
public void setFromBtn(long fromBtn) {
    this.fromBtn = fromBtn;
}
public long getToBtn() {
    return toBtn;
}
public void setToBtn(long toBtn) {
    this.toBtn = toBtn;
}   
public Activity getActivity() {
return activity;
}
public void setActivity(Activity activity) {
this.activity = activity;
}       }
Pomagranite
  • 696
  • 5
  • 11