我遇到活动识别问题,我收到以下错误:
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)
ActivityRecognitionResult
课程来自Google Play服务,我该如何解决此错误?
答案 0 :(得分:0)
这是一个工作示例,除了传递活动(仍然没有想到这一点)。基本上你没有CREATOR的东西。下次如果你包含一个代码示例,它会有所帮助。
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;
} }