Thanks, my code works fine now! It was a typo... On Jan 2, 1:47 pm, "Brad Gies" <[email protected]> wrote: > You haven't really given enough information for a definitive answer. Are you > calling the following somewhere? > > public void startService(){ > super.onStart(); > > But, I would also put an "if (b != null)" in as the third line to stop the > next exception. > > Can you post your Stack trace or logcat? It should have enough information > to figure out what the problem is. > > Sincerely, > > Brad Gies > > ----------------------------------------------------------------- > Brad Gies > 27415 Greenfield Rd, # 2, > Southfield, MI, USA > 48076www.bgies.com www.truckerphone.comwww.EDI-Easy.com www.pricebunny.com > ----------------------------------------------------------------- > > Moderation in everything, including abstinence > > -----Original Message----- > From: [email protected] > > [mailto:[email protected]] On Behalf Of > [email protected] > Sent: Friday, January 02, 2009 6:28 AM > To: Android Developers > Subject: [android-developers] Re: Pass state from Activity to Service > > Can anyone help me pls? > > On Jan 1, 3:59 pm, "[email protected]" > <[email protected]> wrote: > > Hi, > > > I'm having hard time working out how to accomplish that. In my > > activity I call my service as follows: > > > private void startService(){ > > Intent myIntent = new Intent(this, MyService.class); > > Bundle b = new Bundle(); > > b.putSerializable("userBean", user); > > myIntent .putExtra("MainActivity", b); > > startService(myIntent ); > > > } > > > Than I try to retrieve the state from the onStart(Intent, int) method > > from my service like that: > > > public void onStart(Intent intent, int startId) { > > Bundle b = intent.getBundleExtra("MainActivity"); > > User user = (User) b.getSerializable("userBean"); > > Log.i("User Name:", user.getName()); > > > } > > > Everytime the service gets called, the compiler throws a > > NullPointerException from the onStart(Intent, int) method. > > > Pls help! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

