[android-beginners] Re: onHandleIntent(Intent) method does not get called

2010-06-24 Thread appsgrrl
Hi -- Okay, I got further!  Yay!  It turns out that I also had to call
super.onCreate()  to avoid the null pointer exception.
So, if I call super.onCreate() and super.onStartCommand(),  my
onHandleIntent() does get excecuted.

Now, my new mystery is why my service gets an onDestroy() call right
after it is started.
I return START_STICKY from onStartCommand, but that does not seem to
have an effect.
I guess I need to understand the life cycle stuff a little more.



On Jun 23, 9:05 pm, appsgrrl bettyoch...@gmail.com wrote:
 Hi -- You know, that was one of the first things I had thought of, so
 I put a call to super.onHandleIntent() in my class code.
 However, I got a NullPointerException  from IntentService.onStart(),
 which is called from IntentService.onStartCommand(), which is from my
 class's onStartCommand()

 I tried it again, and played with the arguments to no avail.  I assume
 that I use my incoming arguments and pass them  to the
 super.onStartCommand(), correct?

 Thanks again for your help

 On Jun 23, 7:47 am, Mark Murphy mmur...@commonsware.com wrote:

  On Wed, Jun 23, 2010 at 10:37 AM, appsgrrl bettyoch...@gmail.com wrote:
   Thanks for replying.   I also have a logging printout in the
   onStartCommand() method, and that does show as being called.
   If onStartCommand() is called, doesn't that mean my startService()
   from my Activity has indeed started my IntentService?

  Yes. However, be sure you are chaining to the superclass in
  onStartCommand() -- otherwise, you will block IntentService from
  dispatching your Intent to onHandleIntent() via the background thread.

   Who ultimately calls onHandleIntent()?

  IntentService does.

  --
  Mark Murphy (a Commons 
  Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

  _The Busy Coder's Guide to *Advanced* Android Development_
  Version 1.6 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


Re: [android-beginners] Re: onHandleIntent(Intent) method does not get called

2010-06-24 Thread Kostya Vasilyev

24.06.2010 10:49, appsgrrl пишет:

Hi -- Okay, I got further!  Yay!  It turns out that I also had to call
super.onCreate()  to avoid the null pointer exception.
So, if I call super.onCreate() and super.onStartCommand(),  my
onHandleIntent() does get excecuted.
   


Great. Both superclass methods need to get called - onCreate() set up a 
worker thread, and onStartCommand() queues the intent to this thread, 
which ultimately calls your onHandleIntent()

Now, my new mystery is why my service gets an onDestroy() call right
after it is started.
I return START_STICKY from onStartCommand, but that does not seem to
have an effect.
I guess I need to understand the life cycle stuff a little more.
   


This is intended behaviour. The service is stopped when the last queued 
intent has been processed by your subclass's onHandleIntent().


--

Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: onHandleIntent(Intent) method does not get called

2010-06-23 Thread appsgrrl
Hi --

Thanks for replying.   I also have a logging printout in the
onStartCommand() method, and that does show as being called.
If onStartCommand() is called, doesn't that mean my startService()
from my Activity has indeed started my IntentService?

Who ultimately calls onHandleIntent()?  That's what I cannot figure
out from the docs.

Betty


On Jun 23, 4:02 am, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Jun 23, 2010 at 1:03 AM, appsgrrl bettyoch...@gmail.com wrote:
  I'm tryng to get an IntentService to work, and I have extended
  IntentService, and I implemented a onHandletIntent(Intent) method.  I
  put some logging in there, but this method never gets called.

  I must be doing something really dumb, but I don't know what it is.

  Is there something else I need to implement or override, or whatever,
  to make this work?

 No, that's pretty much it. Are you sure whatever is supposed to be
 calling startService() is actually calling startService()?

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to *Advanced* Android Development_
 Version 1.6 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


Re: [android-beginners] Re: onHandleIntent(Intent) method does not get called

2010-06-23 Thread Mark Murphy
On Wed, Jun 23, 2010 at 10:37 AM, appsgrrl bettyoch...@gmail.com wrote:
 Thanks for replying.   I also have a logging printout in the
 onStartCommand() method, and that does show as being called.
 If onStartCommand() is called, doesn't that mean my startService()
 from my Activity has indeed started my IntentService?

Yes. However, be sure you are chaining to the superclass in
onStartCommand() -- otherwise, you will block IntentService from
dispatching your Intent to onHandleIntent() via the background thread.

 Who ultimately calls onHandleIntent()?

IntentService does.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_
Version 1.6 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


Re: [android-beginners] Re: onHandleIntent(Intent) method does not get called

2010-06-23 Thread Kostya Vasilyev

Betty,

Make sure your service calls base class methods in onCreate() and 
onStart(). Intents for processing are queued to a worker thread by 
IntentService.onStart. The worker thread is set up by onCreate.


class BettysService extends IntentService {

@Override
public void onCreate() {
... logging here ...
super.onCreate();
}

@Override
public void onStart(Intent intent, int startId) {
... logging here...
super.onStart(intent, startId);
}
.
}

BTW, Android source can be found here:

http://www.netmite.com/android/mydroid/1.6/frameworks/base/core/java/android/app/

-- Kostya

23.06.2010 18:37, appsgrrl пишет:

Hi --

Thanks for replying.   I also have a logging printout in the
onStartCommand() method, and that does show as being called.
If onStartCommand() is called, doesn't that mean my startService()
from my Activity has indeed started my IntentService?

Who ultimately calls onHandleIntent()?  That's what I cannot figure
out from the docs.

Betty


On Jun 23, 4:02 am, Mark Murphymmur...@commonsware.com  wrote:
   

On Wed, Jun 23, 2010 at 1:03 AM, appsgrrlbettyoch...@gmail.com  wrote:
 

I'm tryng to get an IntentService to work, and I have extended
IntentService, and I implemented a onHandletIntent(Intent) method.  I
put some logging in there, but this method never gets called.
   
 

I must be doing something really dumb, but I don't know what it is.
   
 

Is there something else I need to implement or override, or whatever,
to make this work?
   

No, that's pretty much it. Are you sure whatever is supposed to be
calling startService() is actually calling startService()?

--
Mark Murphy (a Commons 
Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_
Version 1.6 Available!
 
   



--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: onHandleIntent(Intent) method does not get called

2010-06-23 Thread appsgrrl
Hi -- You know, that was one of the first things I had thought of, so
I put a call to super.onHandleIntent() in my class code.
However, I got a NullPointerException  from IntentService.onStart(),
which is called from IntentService.onStartCommand(), which is from my
class's onStartCommand()

I tried it again, and played with the arguments to no avail.  I assume
that I use my incoming arguments and pass them  to the
super.onStartCommand(), correct?

Thanks again for your help




On Jun 23, 7:47 am, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Jun 23, 2010 at 10:37 AM, appsgrrl bettyoch...@gmail.com wrote:
  Thanks for replying.   I also have a logging printout in the
  onStartCommand() method, and that does show as being called.
  If onStartCommand() is called, doesn't that mean my startService()
  from my Activity has indeed started my IntentService?

 Yes. However, be sure you are chaining to the superclass in
 onStartCommand() -- otherwise, you will block IntentService from
 dispatching your Intent to onHandleIntent() via the background thread.

  Who ultimately calls onHandleIntent()?

 IntentService does.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to *Advanced* Android Development_
 Version 1.6 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en