Skip to content Skip to sidebar Skip to footer

Use Android Application Class Run A Thread Background To Post Some Data To Webservice

Could I write a thread in Android the Application class? This thread is running every five minutes to post data to a webservice. public class MyApplication extends Application { @

Solution 1:

Intent photosIntent = newIntent(this, MyService.class);
pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0,photosIntent, PendingIntent.FLAG_UPDATE_CURRENT);
alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 5*60*1000,5*60*1000, pendingIntent);

In MyService is a Service Class write your stuff in onstart to send request to webservices. This service will call for every 5minutes.

Hope this helps.

Thanks

Post a Comment for "Use Android Application Class Run A Thread Background To Post Some Data To Webservice"