Hi, I'm trying to make a service sync data every *user defined
period*, having watched some of the I/O videos I've realised that the
best way to do this is via an alarm, as a result I have a couple of
questions.

I have the following method to create the alarm:

        /**
         * Set the alarm for the service to download the data periodically at
the passed interval
         */
        private void setAlarm(long interval)
        {
                AlarmManager am = (AlarmManager)
this.getSystemService(ALARM_SERVICE);
                Intent intent = new Intent(this, DownloadData.class);
                PendingIntent pendingIntent = PendingIntent.getService(this,0,
intent, 0);
                interval = interval * DateUtils.MINUTE_IN_MILLIS; //convert 
interval
from minutes to milliseconds
                long firstWake = System.currentTimeMillis() + 500;
                am.setInexactRepeating(AlarmManager.RTC_WAKEUP, firstWake, 
interval,
pendingIntent); //group updates with other system services
        }

but I'm not sure if I should put this method in the service it'self of
in Activity?

Also while I was writing this in the service class I was trying to
reference a string value in the res file but it wouldn't let me, I can
reference it via an Activity (this.getString(R.string.sync_time_min))
but when I tried this in the service eclipse kept saying it couldn't
be resolved.

Any ideas? what do I need to add to be able to reference the res file
from my service or can this not be done?

Cheers
Steve

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to