I have a service that starts in a separate process:
<service android:name=".services.UploadService" android:process=":UploadServiceProcess" />
And I can successfully bind to it using bindService (). My problem occurs when I try to send a message by calling Messenger.send ():
service.send(Message.obtain(null, UploadService.MESSAGE_UPLOAD_REQUEST, uploadRequest));
where uploadRequest is a custom object that implements Parcelable
public class UploadRequest implements Parcelable { public File file; public boolean deleteOnUpload;
public UploadRequest(File file, boolean deleteOnUpload) { this.file = file; this.deleteOnUpload = deleteOnUpload; } private UploadRequest(Parcel in) { this.file = new File(in.readString()); } public int describeContents() { return 0; } public void writeToParcel(Parcel dest, int flags) { dest.writeString(this.file.getPath()); } public static final Parcelable.Creator<UploadRequest> CREATOR = new Parcelable.Creator<UploadRequest>() { public UploadRequest createFromParcel(Parcel in) { return new UploadRequest(in); } public UploadRequest[] newArray(int size) { return new UploadRequest[size]; } };
} Code>
I set a breakpoint in my handleMessage services, but my application never hits a breakpoint. However, if I send null instead of using my custom UploadRequest object, I get to the handleMessage breakpoint as I expected, but obviously I can’t do anything at this point. I checked the .getPath () file when calling writeToParcel returns a non-empty String. This makes me believe that something is not in my UploadRequest class, but from googling I see nothing wrong with my class. Any ideas?
Nelson monterroso
source share