Archana wrote:
> 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.
>

use  IntentService as a sa base base class, read its docs and
everything will be obvious

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

Reply via email to