nickmao1985 / apndroid

Automatically exported from code.google.com/p/apndroid
0 stars 0 forks source link

API for service needs #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
We need to provide API to call from services.
Currently it is planned to use ordered broadcast for it.

Original issue reported on code.google.com by zeldigas on 20 Apr 2010 at 4:24

GoogleCodeExporter commented 9 years ago
Hi there,

I'm currently working on a patch for this using a service which clients can 
bind to, to get the status and request switching status.

I hope to finish in a few days. Would you guys be interested? Who should I 
email to? Or should I attach a file to this issue. I don't want to do a fork so 
if you guys are already working on this can you let me know so I can stop and 
just be patient :)

Phil

Original comment by wingp...@gmail.com on 14 Jun 2010 at 11:19

GoogleCodeExporter commented 9 years ago
What about ordered broadcast? Is service more convinient in such things?
As far as i know using a service means that it will work in background 
(separate thread). Am i right, or it is more like activity (called, perform 
request and then finished)?

Original comment by zeldigas on 14 Jun 2010 at 2:04

GoogleCodeExporter commented 9 years ago
The service will remain available in the same way that the activity does. When 
no clients are using it, it will take up a very small amount of memory, but no 
processor cycles. This is true of the activity and the broadcast receiver as 
well unless you are using a task killer, as I understand it.

If this is a problem for you I can tell the service to kill itself when the 
last client unbinds? but this is less efficient CPU wise. 

I didn't like the idea of ordered broadcast as you would have to broadcast an 
intent and receive that same intent asynchronously, whereas the service can be 
accessed synchronously. You'd also have to coordinate the priority of the 
broadcast receivers on the client and on APNdroid to make sure they are 
processed in the correct order. It didn't seem like the "right" way of doing 
it, to me at least.

I'm leaving in the startActivityForResult way of doing things so people will 
have a choice?

Original comment by wingp...@gmail.com on 14 Jun 2010 at 2:19

GoogleCodeExporter commented 9 years ago
I'll code it so the service is started when the client binds, and then kills 
itself when the client unbinds. It'll only stay running when something is using 
it.

Original comment by wingp...@gmail.com on 14 Jun 2010 at 2:24

GoogleCodeExporter commented 9 years ago
ok, if it gains small amount of memory, than it is no need to kill it.

Original comment by zeldigas on 14 Jun 2010 at 2:30

GoogleCodeExporter commented 9 years ago
Hi there,

I have finished my patch for you to have a look at.

Notes:
- It is a git extended format patch as there are binary files (the api jar)
- I have added two jars required for the android ant lib. 
http://code.google.com/p/autoandroid/wiki/AndroidAnt
- I have modified the api example so that you can choose to use the service or 
the original activity method.

I used eclipse/MercurialEclipse to export the patch, hopefully it will import 
OK other wise let me know and we can try just a zip file for you to diff 
against.

Original comment by wingp...@gmail.com on 15 Jun 2010 at 12:27

Attachments:

GoogleCodeExporter commented 9 years ago
Hi there,

Please disregard the previous file and use this one. I have made the methods on 
the service thread and the SwitchingAndMessagingUtils synchronized in case of 
multiple clients.

Original comment by wingp...@gmail.com on 15 Jun 2010 at 12:53

Attachments:

GoogleCodeExporter commented 9 years ago
Hi there,

Are you still interested in this? I have created a clone of your repository 
here http://code.google.com/r/wingphil-service/source/browse/ for you to review 
the changes.

Phil

Original comment by wingp...@gmail.com on 21 Jun 2010 at 3:18

GoogleCodeExporter commented 9 years ago
Hi, Phil!
Thank you for your help!

Yes, we are interested in your code, but this days all of us was insufficient 
free time to add your patch.
I'll try to do this till this weekend.

Original comment by zeldigas on 21 Jun 2010 at 4:32

GoogleCodeExporter commented 9 years ago
applied patch in revision 
http://code.google.com/p/apndroid/source/detail?r=47696dedcb68672a53af1620679cac
49bfa2d462

thanks again Phil!

Original comment by zeldigas on 21 Sep 2010 at 6:01