Closed trebormat closed 8 years ago
@trebormat try to change SimpleDataEvent(Parcel in)
from protected
to public
. That must help
I have the same. From the Wear I issue:
EventBus.getDefault().postRemote(new StopRemoteEvent(settings), context);
Funny the message I get on Wear. This is not a local: D/Event﹕ No local subscribers registered for event class com.xyz.common.event.StartRemoteEvent
And on the Mobile:
D/BusWearTag﹕ syncEvent error:
Code Wear in ... WearableActivity:
EventBus.getDefault().postRemote(new StartRemoteEvent(settings), context);
Code:
public class StopRemoteEvent extends GpsSettingsModelBaseEvent {
public StopRemoteEvent(GpsSettingsModel settings) {
super(settings);
}
}
Code:
public class GpsSettingsModelBaseEvent implements Parcelable {
public GpsSettingsModel mData;
public GpsSettingsModelBaseEvent(GpsSettingsModel data) {
this.mData = data;
}
public GpsSettingsModelBaseEvent() {
}
public GpsSettingsModel getData() {
return mData;
}
public boolean hasData() {
return mData != null;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(this.mData, 0);
}
public GpsSettingsModelBaseEvent(Parcel in) {
this.mData = in.readParcelable(GpsSettingsModel.class.getClassLoader());
}
public static final Creator<GpsSettingsModelBaseEvent> CREATOR = new Creator<GpsSettingsModelBaseEvent>() {
public GpsSettingsModelBaseEvent createFromParcel(Parcel source) {
return new GpsSettingsModelBaseEvent(source);
}
public GpsSettingsModelBaseEvent[] newArray(int size) {
return new GpsSettingsModelBaseEvent[size];
}
};
Code:
public class GpsSettingsModel implements Parcelable {
public long delay;
public float distance;
public GpsSettingsModel() {
}
public GpsSettingsModel(long delay, float distance) {
this.delay = delay;
this.distance = distance;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(this.delay);
dest.writeFloat(this.distance);
}
protected GpsSettingsModel(Parcel in) {
this.delay = in.readLong();
this.distance = in.readFloat();
}
public static final Creator<GpsSettingsModel> CREATOR = new Creator<GpsSettingsModel>() {
public GpsSettingsModel createFromParcel(Parcel source) {
return new GpsSettingsModel(source);
}
public GpsSettingsModel[] newArray(int size) {
return new GpsSettingsModel[size];
}
};
@Override
public String toString() {
return "GpsSettingsModel{" +
", delay=" + delay +
", distance=" + distance +
'}';
}
}
Code Mobile in ... extends WearableListenerService:
public void onEvent(StopRemoteEvent event) {
doSomething();
}
Only simple Class with Parcelable possible. Due to implementation and the sending over the the Wear bus. Reflection does not find the Parcelable constructor otherwise. Also make sure your methods is public and not private or protected.
I have an issue with a simple object Parcelable with just a bundle inside. I use https://github.com/dallasgutauckis/parcelabler I always the same error : D/BusWearTag﹕ syncEvent error: [class android.os.Parcel]
Could you help me to find the error. Because your library is very great for simple type. It works very fine, but I need a more complexe object. Thanks for your help.