Re: [android-developers] Re: Passing objects to new intents
Serializable has higher overhead than Android's similar built-in interface, Parcelable. Try using Parcelable if possible, and consider support for Java serialization a fall-back (for compatibility with legacy and library code). -- Kostya 28.01.2011 14:44, maccoy пишет: why not class implementes Serializable myBundle.putSerializable( and get the class back?? is there a performance issue? On Dec 30 2010, 5:21 pm, TreKingtreking...@gmail.com wrote: On Thu, Dec 30, 2010 at 3:36 AM, maomaostevencao maomaosteven...@hotmail.com wrote: What you have said is the common way to pass arguments to an activity. Right. But my question is about how to pass an object of user defined class to an activity. Passing a user defined object to an Activity is not much different than passing, say, an int. Re-read this thread - that's exactly what was discussed. One guy said that it could be done by implementing some common functions for this activity and calling those functions to pass object to this activity, but how I can get the activity reference would be a problem. If you're referring to Neilz's post, the second part of that was that he uses static objects - no need to pass an Activity reference around. Each Activity, when active, would use itself to access the user-defined static objects. - TreKinghttp://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com -- 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
Re: [android-developers] Re: Passing objects to new intents
*Hi, I have I9000** with I9000JPJG8 firmeware, Market application work perfectly but, i can't find Google maps in the Market, I have found some articles that says there is a license issue, I used the bar code of maps application, but Market return no application. Any ideas. * -- 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
Re: [android-developers] Re: Passing objects to new intents
Perhaps, a mismatch of title and content. Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com On Fri, Jan 28, 2011 at 5:26 PM, Mohamed KARAMI karami...@gmail.com wrote: *Hi, I have I9000** with I9000JPJG8 firmeware, Market application work perfectly but, i can't find Google maps in the Market, I have found some articles that says there is a license issue, I used the bar code of maps application, but Market return no application. Any ideas. * -- 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.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- 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
RE: [android-developers] Re: Passing objects to new intents
hi treking, What you have said is the common way to pass arguments to an activity. But my question is about how to pass an object of user defined class to an activity. One guy said that it could be done by implementing some common functions for this activity and calling those functions to pass object to this activity, but how I can get the activity reference would be a problem. As Mark said you can't really do this if you use any of the derived Activity classes (List, Tab, and especially Map). For this kind of common activity stuff I created a proxy of sorts - a class that takes an instance of an Activity and implements functions that are common for all. Then each Activity just creates an instance of this proxy with itself and uses it to do the common logic stuff. It's a little more verbose, but works to centralize the common code given the restrictive inheritance hierarchy. _ From: android-developers@googlegroups.com [mailto:android-develop...@googlegroups.com] On Behalf Of TreKing Sent: Thursday, December 30, 2010 7:56 AM To: android-developers@googlegroups.com Subject: Re: [android-developers] Re: Passing objects to new intents On Tue, Dec 28, 2010 at 11:52 PM, maomaostevencao maomaosteven...@hotmail.com wrote: If I want to load a new activity and pass some of arguments using this way, I have to get the reference of this new activity, but seems platform doesn't provide any API to get it. How can you do it? I mean how I can get the reference of the new activity You do not need a reference to the new activity. You launch an intent with the proper variables, then the new activity is launched and within it you use getIntent() to get the Intent that launched it, including any variables you passed along. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- 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 -- 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
Re: [android-developers] Re: Passing objects to new intents
On Thu, Dec 30, 2010 at 3:36 AM, maomaostevencao maomaosteven...@hotmail.com wrote: What you have said is the common way to pass arguments to an activity. Right. But my question is about how to pass an object of user defined class to an activity. Passing a user defined object to an Activity is not much different than passing, say, an int. Re-read this thread - that's exactly what was discussed. One guy said that it could be done by implementing some common functions for this activity and calling those functions to pass object to this activity, but how I can get the activity reference would be a problem. If you're referring to Neilz's post, the second part of that was that he uses static objects - no need to pass an Activity reference around. Each Activity, when active, would use itself to access the user-defined static objects. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- 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
Re: [android-developers] Re: Passing objects to new intents
On Tue, Dec 28, 2010 at 11:52 PM, maomaostevencao maomaosteven...@hotmail.com wrote: If I want to load a new activity and pass some of arguments using this way, I have to get the reference of this new activity, but seems platform doesn't provide any API to get it. How can you do it? I mean how I can get the reference of the new activity You do not need a reference to the new activity. You launch an intent with the proper variables, then the new activity is launched and within it you use getIntent() to get the Intent that launched it, including any variables you passed along. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- 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
RE: [android-developers] Re: Passing objects to new intents
As Mark said you can't really do this if you use any of the derived Activity classes (List, Tab, and especially Map). For this kind of common activity stuff I created a proxy of sorts - a class that takes an instance of an Activity and implements functions that are common for all. Then each Activity just creates an instance of this proxy with itself and uses it to do the common logic stuff. It's a little more verbose, but works to centralize the common code given the restrictive inheritance hierarchy. Interesting.But I have a question. If I want to load a new activity and pass some of arguments using this way, I have to get the reference of this new activity, but seems platform doesn't provide any API to get it. How can you do it? I mean how I can get the reference of the new activity. thanks. _ From: android-developers@googlegroups.com [mailto:android-develop...@googlegroups.com] On Behalf Of TreKing Sent: Monday, December 06, 2010 5:35 AM To: android-developers@googlegroups.com Subject: Re: [android-developers] Re: Passing objects to new intents On Sun, Dec 5, 2010 at 2:42 PM, Neilz neilhorn...@gmail.com wrote: 1) This is useful as you can put a lot of common methods and vars in there,,, As Mark said you can't really do this if you use any of the derived Activity classes (List, Tab, and especially Map). For this kind of common activity stuff I created a proxy of sorts - a class that takes an instance of an Activity and implements functions that are common for all. Then each Activity just creates an instance of this proxy with itself and uses it to do the common logic stuff. It's a little more verbose, but works to centralize the common code given the restrictive inheritance hierarchy. 2) I created a load of static objects which, when launching my intents, I populate the static objects so that when the next activity is launched they're there ready. No bundles, no parcelables, simple. What happens when: You start Activity A which initializes a bunch of static objects. From A you launch Activity B which is depending on these static being initialized by A. You press Home and do other things for an hour or so, eventually your app gets wiped from memory, including the statics. You come back to your Activity, which will start at B since that was the last thing the user saw. A will NOT be called to initialize your statics and B will be using default or non-initialized static data. I would be very careful with using static data to store instance state across Activities. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- 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 -- 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
Re: [android-developers] Re: Passing objects to new intents
On Sun, Dec 5, 2010 at 3:42 PM, Neilz neilhorn...@gmail.com wrote: Now maybe this is obvious, but I must say I haven't seen this in any other examples. I'm wondering if there's something 'wrong' with this, any reason why this shouldn't be done? 1. Watch for memory leaks. Do not put things in static contexts that might reference another Activity, for example (e.g., a widget). 2. Since Java does not support multiple inheritance, the base class may interfere with uses of other activity classes (e.g., PreferenceActivity, MapActivity), or require code duplication. Rather than having a load of static objects, you could have just one singleton that itself holds onto a load of other data. That will make it easier for you to migrate to another approach (e.g., Service, custom Application) if you so choose to later. It also consolidates your initialization, makes it a bit easier to give the static data more smarts about its static-ness (e.g., LRU algorithms to minimize memory creep), etc. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android App Developer Books: http://commonsware.com/books -- 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
Re: [android-developers] Re: Passing objects to new intents
On Sun, Dec 5, 2010 at 2:42 PM, Neilz neilhorn...@gmail.com wrote: 1) This is useful as you can put a lot of common methods and vars in there,,, As Mark said you can't really do this if you use any of the derived Activity classes (List, Tab, and especially Map). For this kind of common activity stuff I created a proxy of sorts - a class that takes an instance of an Activity and implements functions that are common for all. Then each Activity just creates an instance of this proxy with itself and uses it to do the common logic stuff. It's a little more verbose, but works to centralize the common code given the restrictive inheritance hierarchy. 2) I created a load of static objects which, when launching my intents, I populate the static objects so that when the next activity is launched they're there ready. No bundles, no parcelables, simple. What happens when: You start Activity A which initializes a bunch of static objects. From A you launch Activity B which is depending on these static being initialized by A. You press Home and do other things for an hour or so, eventually your app gets wiped from memory, including the statics. You come back to your Activity, which will start at B since that was the last thing the user saw. A will NOT be called to initialize your statics and B will be using default or non-initialized static data. I would be very careful with using static data to store instance state across Activities. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- 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
Re: [android-developers] Re: Passing objects to new intents
On Tue, Nov 30, 2010 at 1:11 AM, Doug beafd...@gmail.com wrote: Parcelable is not such a headache once you get the boilerplate code out of the way. It's not only the repetitive CREATOR stuff. I found that if I send a custom parcelable to a Service which was to start after my main Activity had gone away, loading my object would fail (class loader not available or something ... there was a thread or two about it a while ago). This was my major motivation for ditching parcelable. Parcelable is an advantage if you need to pass arrays of such objects around. You can't attach arrays of Bundles to intents without your own mechanisms. Sure you can. Bundle extends parcelable, so you can attach an array of parcelables that are Bundles. Or, better yet, you can pass an ArrayList of Bundles with putParcelableArrayListExtra(), which takes advantage of the generics interface. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- 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