Should I have the alarm manager as a service?(as I want the application to
be executed always)...
Here is my service:
public class PollService extends Service
{
private PendingIntent pendingIntent;
private AlarmManager alarmManager;
private Calendar calendar;
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public boolean onUnbind(Intent intent) {
return super.onUnbind(intent);
}
@Override
public void onCreate() {
Toast.makeText(getApplicationContext(), "Service Started",
Toast.LENGTH_SHORT).show();
alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent myIntent = new Intent(this, PollService.class);
pendingIntent = PendingIntent.getService(this, 0, myIntent, 0);
calendar = Calendar.getInstance();
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.MILLISECOND, 300000);// Polling for every 5 minutes
alarmManager.set(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis(),pendingIntent);
}
@Override
public void onDestroy() {
super.onDestroy();
alarmManager.cancel(pendingIntent);
}
}
But where do I define connecting to the server and getting the contents?
Thank you.
On Tuesday, October 9, 2012 12:27:05 PM UTC+3, skink wrote:
>
>
>
> Archana wrote:
> > Can you please let me know how to use Alarm Manager as service?
> >
> >
>
>
> sure, google for:
> android alarmmanager example
>
> pskink
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en