Why won't Intent pass along the extras

by frizzo » Wed, 11 Mar 2009 13:45:47 GMT


Sponsored Links
 I have a class object that I want to pass from one screen to another.
So I made it inherit from Parcelable and added the following code to
my class:

public class ItemDescription implements Parcelable {
       /// property setters and getters

        public int describeContents() {
                // TODO Auto-generated method stub
                return 0;
        }

        public void writeToParcel(Parcel out, int flags) {
                out.writeInt(mData);
        }

        public static final Parcelable.Creator<ItemDescription> CREATOR = new
Parcelable.Creator<ItemDescription>() {
        public ItemDescription createFromParcel(Parcel in) {
            return new ItemDescription(in);
        }

        public ItemDescription[] newArray(int size) {
            return new ItemDescription[size];
        }
    };
}

In response to an event, I do kick off another screen (Intent) and put
extras into it:

        Intent mIntent = new Intent(v.getContext(), Item.class);

        Parcelable itemDesc = getItemDescription(preset);  // returns
ItemDescription
        mIntent.putExtra("com.vbrad.android.mystapp.item1", itemDesc);
        startActivity(mIntent);


In the onCreate event of this new activity, I attempt o retrieve the
contents of the itemDesc object in the following manner:


        Intent intent = getIntent();
        Parcelable p = intent.getParcelableExtra("com.vbrad.android.
mystapp.item1");
        ItemDescription itemDesc = (ItemDescription) p;

However, the itemDesc object is unpopulated - all the internal
variables are at default values (e.g. 0 for numeric types, null for
everything else).  It's like it was just created.

What am I missing here?

Thanks.


--~--~---------~--~----~------------~-------~--~----~



Why won't Intent pass along the extras

by Steven Farley » Wed, 11 Mar 2009 21:36:22 GMT


 I have done this succesfully with a Serializable object added with
Intent#putExtra(String, Serializable).  Is there some reason why
Parcelable is a better choice in your case?

++Steve



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Why won't Intent pass along the extras

by frizzo » Thu, 12 Mar 2009 13:26:03 GMT


 I have no idea whether it's a better choice or not.  I asked the
question here as to how to do it and was given Parcelable as the
answer.  I'll give it a try with serializable.




--~--~---------~--~----~------------~-------~--~----~



Why won't Intent pass along the extras

by frizzo » Thu, 12 Mar 2009 14:45:08 GMT


 Can you post an example by any chance?





--~--~---------~--~----~------------~-------~--~----~



Why won't Intent pass along the extras

by frizzo » Sat, 14 Mar 2009 12:35:11 GMT


 Serializable works.






--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. hid_parse_report, what happens next?

Hello All,

Can some one let me know, how does the hid class driver's
hid_parse_report() work?

My understanding is that :
1. It parses the hid report using following dispatchers:
                hid_parser_main,
                hid_parser_global,
                hid_parser_local,
                hid_parser_reserved
2. These dispatchers parse the report and fills up the hid_parser
*parser structure.

3. Both hidp_parse and ushid_parse calls hid_parse_report().

But, what happens after this? How are the parsed reports then sent to
the input subsystem?

Any clue on this would be very helpful to me.

Thanks,
Sunil



-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: 

2. power manager (Light off) in android

hii .....

Currently i m facing a problem to switch off light in android application. i
m trying to power manager ---- gotosleep method but its giving a below
problem .

*java.lang.RuntimeException: Unable to start activity
ComponentInfo{org.bhavesh/org.bhavesh.mainactivity}: *
*
*
*java.lang.SecurityException: Neither user 10024 nor current process has
android.permission.DEVICE_POWER.*

but i already given  a android.permission.DEVICE_POWER in manifest file.

can any one tell me why its happened in android. yaa any other method to off
the light in android..

Thank you in advanced

With Regrads
bhavesh

-- 

3. Wtc batre box 5000 mah & acc android..

4. Android finishActivity()

5. How to launch browser from wallpaper?

6. Tmobile Native IM versi 1.1.2 worked via gprs/3G and wifi

7. Tmobile Native IM versi 1.1.2 worked via gprs/3G and wifi