I m new to Android
and have developed an app that inserts and update data into remote
MySql database and i m able to display it in list view also using JSON
object.
Now i want notify app when ever i insert or update data in database using background
services even though less efficient than GCM
.
public class Myservice extends Service
{
@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
//TODO do something useful
return Service.START_NOT_STICKY;
}
@Override
public IBinder onBind(Intent intent)
{
//TODO for communication return IBinder implementation
return null;
}
}
I referred some links and vogella tutorials but it is for alarm manager.I need for database Can somebody provide some code examples.
Running a background task and polling your server for update is a very bad idea, as it has pleanty of drawbacks. I would advice you to use GCM. As its very easy to implement.(GCM with php and GCM with java)
However, Since you want a service based approach:
Try using the alarm managers, as they can save you on power.
Note:
I will still urge you to use gcm as they are very efficient at doing that one thing(polling for updates).