android - Combining some service code with mysql -


my goal connect remote mysql db through php make request, find out if there new messages available , if answer yes, send notification device display it. there should working example of this, since it's base of serious app deals updates and/or messaging. php looks this:

<?php $con=mysql_connect("localhost","username","password");   if(!$con)  die('could not connect: ' .mysql_error());   mysql_select_db("mydatabasename",$con);   $result = mysql_query("select count(*) (select * notificari n, notificari_destinatii d n.dest_notif_id=d.id_master) tbl  id_user=247 , date(data_notif)=date(now())");   while($row=mysql_fetch_assoc($result)){  $output[]=$row;  }   print(json_encode($output));  mysql_close($con);  ?> 

so php tells me number of notifications user 247 received today. want number in service, , compare local (sqlite db table) number of notifications. , if remote number greater local number, want display notification on device saying: "you have new message waiting" , increment local number next time service asks php, remote number , local number equal, no notification fired.

this operation must done every 10 minutes. can done in service? (async call php, sqlite select statement, notification creation)?

how can achieve this? @ first thought of service , went here how can make service cycle, every xx minutes can fire action. implement php call inside service tutorial?

and how can change code add functionality automatically start service above on android boot (code here), user can not have excuse did not receive message because did not start app today.

so how can combine 2 tutorials one?

then stumbled upon this example syncadapters, , confused, because not understand how can apply case? , best approach? service 1 or syncadapter one? have problems understanding concept in code syncadapter apply needs described above

please try , me problem.

thank you

in tutorial starting on boot, need start service broadcastreceiver. , service can either own code make up, or can use sync adapter framework. sounds sync adapter needs, though i've never used it.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -