Reputation: 1054
I am working on a small project where I want to insert RSS feeds into Database all this will be performed in background service, How can I keep looking for new RSS feeds through the service and insert that in database?
Upvotes: 0
Views: 538
Reputation: 2229
What you should do , first refer alarm service . here I set some code stuff regarding that.
Setting Alarm manager let say for every 30 sec. that continuously call your web service that fetch your RSS data from any url.
Intent intent = new Intent(DashboardScreen.this, xxx.class);
PendingIntent pintent = PendingIntent.getService(DashboardScreen.this, 0, intent, 0);
AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 30*1000, pintent);
Inside your xxx class , use asyncTask that call your web service and save that RSS data in to database inside onPostExecute() .apply this and let me know if any query .accept if it is working in your case.
Upvotes: 1