Hi guys,

I'm trying to parcel up a location object and then unparcel it...

        public void testCreator() {

                Location location = new Location("h");
                location.setLatitude(222.0);
                location.setLongitude(20.254);
                location.setAccuracy(10.10f);
                location.setBearing(10.10f);
                location.setProvider("");
                location.setSpeed(200f);
                location.setTime(123456);


                Parcel e = Parcel.obtain();
                e.writeParcelable(location,0);

                Location l = Location.CREATOR.createFromParcel(e);

                assertNotNull(l);
                assertEquals(location.getLatitude(), l.getLatitude());
        }

But its giving me an error..
04-06 23:08:42.087: ERROR/Bundle(5556): readBundle: bad magic number
04-06 23:08:42.097: ERROR/Bundle(5556): readBundle: trace =
java.lang.RuntimeException
04-06 23:08:42.097: ERROR/Bundle(5556):     at
android.os.Parcel.readBundle(Parcel.java:1363)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
android.os.Parcel.readBundle(Parcel.java:1345)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
android.location.Location$1.createFromParcel(Location.java:713)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
android.location.Location$1.createFromParcel(Location.java:717)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
com.john.scratchpad.test.BitmapClassTest.testCreator(BitmapClassTest.java:
27)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
java.lang.reflect.Method.invokeNative(Native Method)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
java.lang.reflect.Method.invoke(Method.java:521)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
junit.framework.TestCase.runTest(TestCase.java:154)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
junit.framework.TestCase.runBare(TestCase.java:127)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
junit.framework.TestResult$1.protect(TestResult.java:106)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
junit.framework.TestResult.runProtected(TestResult.java:124)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
junit.framework.TestResult.run(TestResult.java:109)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
junit.framework.TestCase.run(TestCase.java:118)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:164)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:151)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:
418)
04-06 23:08:42.097: ERROR/Bundle(5556):     at
android.app.Instrumentation
$InstrumentationThread.run(Instrumentation.java:1520)

Is there something that I need to do to the bundle before passing it
to Locaiton.CREATOR?>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to