i'm making an app that has a syncAdapter.
i wish to be able to do a requestSync together with some parameters that will be sent via its bundle . the reason is that i wish to choose what the syncAdapter instance would do .
for some reason , both putSerializable and putIntArray causes the ContentResolver to throw an exception :
08-16 14:34:49.080: E/AndroidRuntime(10318): java.lang.IllegalArgumentException: unexpected value type: java.util.MiniEnumSet
08-16 14:34:49.080: E/AndroidRuntime(10318): at android.content.ContentResolver.validateSyncExtrasBundle(ContentResolver.java:1144)
08-16 14:34:49.080: E/AndroidRuntime(10318): at android.content.ContentResolver.requestSync(ContentResolver.java:1111)
08-16 14:34:49.080: E/AndroidRuntime(10318): at com.sciatis.syncer.syncing.SyncAdapter.requestSync(SyncAdapter.java:100)
08-16 14:34:49.080: E/AndroidRuntime(10318): at
...
why does it happen? is there a way to overcome this ? putting an integer worked fine yet those operations didn't.
am i doing something wrong ? is there a better way to achieve sending parameters to the syncAdapter from an activity ?
ContentResolver.requestSync says:
Only values of the following types may be used in the extras bundle: Integer Long Boolean Float Double String
in that case you could try:
Bundle extras = new Bundle();
int[] arr = new int[] {1,2,3,4};
extras.putInt("arrlen", arr.length);
for (int i = 0; i < arr.length; i++) {
extras.putInt("arr"+ i, arr[i]);
}
and then read those values in SyncAdapter:
Bundle extras; //taken from method params
int[] arr = new int[extras.getInt("arrlen")];
for (int i = 0; i < arr.length; i++) {
arr[i] = extras.getInt("arr"+ i);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With