[android-developers] Re: Service - how to show its progress in Activity

2010-01-03 Thread Molee
lol

I didn't notice that there is a comprehensive explanation in this
website

Thank You

On 1月3日, 上午11時59分, Kumar Bibek coomar@gmail.com wrote:
 AsyncTask gives you more control over how you background work is done.
 You get callbacks for , progress, completion of action, etc.

 You would also get  some etra hooks, like Pre-execute and Post-
 execute.

 http://android-developers.blogspot.com/2009/05/painless-threading.html

 Thanks and Regards,
 Kumar Bibek

 On Jan 3, 7:32 am, Molee leehc...@gmail.com wrote:

  I used to implements the progress of downloading sth in a worker
  thread,

  and new a thread when u choose the corresponding option in the menu
  ( overriding onOptionsItemSelected funciton)

  yet the UI will be frozen once you choose the download option in the
  menu

  Is using asynctask instead the better solution???

  Whats the difference between thread and asynctask???

  Any response is greatly appreciated.

  Thanks,
  Molee

  On 1月3日, 上午1時10分, Kumar Bibek coomar@gmail.com wrote:

   If the service is coupled to your UI, I think AsyncTask would be a
   better solution. Look at the examples for the same.

   But, if the service is completely separate from the UI, then you have
   to bind to the service, and then check it's progress.

   Thanks and Regards,
   Kumar Bibek

   On Jan 2, 4:54 pm, fhucho fhu...@gmail.com wrote:

Hi,
I have a service that downloads something from the Internet, it shows
progress in notifications and in MyActivity (only when MyActivity is
on foreground of course). How should the service post the progress to
MyActivity? I know this could be done somehow with IBind but can I
just simply do this in MyActivity:

MySevice.myActivity = this;
startService(new Intent());

?
From MyService I can now call MyActivity's methods because I have a
static reference to it in MySevice.myActivity, so I can call e.g.
myActivity.sendProgress(63).

-- 
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


[android-developers] Re: Service - how to show its progress in Activity

2010-01-02 Thread Kumar Bibek
If the service is coupled to your UI, I think AsyncTask would be a
better solution. Look at the examples for the same.

But, if the service is completely separate from the UI, then you have
to bind to the service, and then check it's progress.

Thanks and Regards,
Kumar Bibek

On Jan 2, 4:54 pm, fhucho fhu...@gmail.com wrote:
 Hi,
 I have a service that downloads something from the Internet, it shows
 progress in notifications and in MyActivity (only when MyActivity is
 on foreground of course). How should the service post the progress to
 MyActivity? I know this could be done somehow with IBind but can I
 just simply do this in MyActivity:

 MySevice.myActivity = this;
 startService(new Intent());

 ?
 From MyService I can now call MyActivity's methods because I have a
 static reference to it in MySevice.myActivity, so I can call e.g.
 myActivity.sendProgress(63).

-- 
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


[android-developers] Re: Service - how to show its progress in Activity

2010-01-02 Thread Molee
I used to implements the progress of downloading sth in a worker
thread,

and new a thread when u choose the corresponding option in the menu
( overriding onOptionsItemSelected funciton)

yet the UI will be frozen once you choose the download option in the
menu

Is using asynctask instead the better solution???

Whats the difference between thread and asynctask???

Any response is greatly appreciated.

Thanks,
Molee

On 1月3日, 上午1時10分, Kumar Bibek coomar@gmail.com wrote:
 If the service is coupled to your UI, I think AsyncTask would be a
 better solution. Look at the examples for the same.

 But, if the service is completely separate from the UI, then you have
 to bind to the service, and then check it's progress.

 Thanks and Regards,
 Kumar Bibek

 On Jan 2, 4:54 pm, fhucho fhu...@gmail.com wrote:

  Hi,
  I have a service that downloads something from the Internet, it shows
  progress in notifications and in MyActivity (only when MyActivity is
  on foreground of course). How should the service post the progress to
  MyActivity? I know this could be done somehow with IBind but can I
  just simply do this in MyActivity:

  MySevice.myActivity = this;
  startService(new Intent());

  ?
  From MyService I can now call MyActivity's methods because I have a
  static reference to it in MySevice.myActivity, so I can call e.g.
  myActivity.sendProgress(63).

-- 
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


[android-developers] Re: Service - how to show its progress in Activity

2010-01-02 Thread Kumar Bibek
AsyncTask gives you more control over how you background work is done.
You get callbacks for , progress, completion of action, etc.

You would also get  some etra hooks, like Pre-execute and Post-
execute.

http://android-developers.blogspot.com/2009/05/painless-threading.html

Thanks and Regards,
Kumar Bibek

On Jan 3, 7:32 am, Molee leehc...@gmail.com wrote:
 I used to implements the progress of downloading sth in a worker
 thread,

 and new a thread when u choose the corresponding option in the menu
 ( overriding onOptionsItemSelected funciton)

 yet the UI will be frozen once you choose the download option in the
 menu

 Is using asynctask instead the better solution???

 Whats the difference between thread and asynctask???

 Any response is greatly appreciated.

 Thanks,
 Molee

 On 1月3日, 上午1時10分, Kumar Bibek coomar@gmail.com wrote:

  If the service is coupled to your UI, I think AsyncTask would be a
  better solution. Look at the examples for the same.

  But, if the service is completely separate from the UI, then you have
  to bind to the service, and then check it's progress.

  Thanks and Regards,
  Kumar Bibek

  On Jan 2, 4:54 pm, fhucho fhu...@gmail.com wrote:

   Hi,
   I have a service that downloads something from the Internet, it shows
   progress in notifications and in MyActivity (only when MyActivity is
   on foreground of course). How should the service post the progress to
   MyActivity? I know this could be done somehow with IBind but can I
   just simply do this in MyActivity:

   MySevice.myActivity = this;
   startService(new Intent());

   ?
   From MyService I can now call MyActivity's methods because I have a
   static reference to it in MySevice.myActivity, so I can call e.g.
   myActivity.sendProgress(63).

-- 
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