I think that you should let your service be started by a boot broadcastReceiver, then ask AlarmManager to relaunch it every now and then public class DbUpdateService extends Service { //compat to support older devices @Override public void onStart(Intent intent, int startId) { onStartCommand(intent, 0, startId); } @Override public int onStartCommand (Intent intent, int flags, int startId){ //your method to update the database UpdateTheDatabaseOnceNow(); //reschedule me to check again tomorrow Intent serviceIntent = new Intent(DbUpdateService. This,DbUpdateService. Class); PendingIntent restartServiceIntent = PendingIntent.
GetService(DbUpdateService. This, 0, serviceIntent,0); AlarmManager alarms = (AlarmManager)getSystemService(ALARM_SERVICE); // cancel previous alarm alarms. Cancel(restartServiceIntent); // schedule alarm for today + 1 day Calendar calendar = Calendar.getInstance(); calendar.
Add(Calendar. DATE, 1); // schedule the alarm alarms. Set(AlarmManager.
RTC_WAKEUP, calendar.getTimeInMillis(), restartServiceIntent); return Service. START_STICKY; } } To start your service at boot time use this : import android.content. BroadcastReceiver; import android.content.
Context; import android.content. Intent; public class serviceAutoLauncher extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { Intent serviceIntent = new Intent(context,DbUpdateService. Class); context.
StartService(serviceIntent); } } Finally add this to your manifest to schedule your serviceAutoLauncher to be launched at each boot: receiver android:name="serviceAutoLauncher".
I think that you should let your service be started by a boot broadcastReceiver, then ask AlarmManager to relaunch it every now and then. Public class DbUpdateService extends Service { //compat to support older devices @Override public void onStart(Intent intent, int startId) { onStartCommand(intent, 0, startId); } @Override public int onStartCommand (Intent intent, int flags, int startId){ //your method to update the database UpdateTheDatabaseOnceNow(); //reschedule me to check again tomorrow Intent serviceIntent = new Intent(DbUpdateService. This,DbUpdateService.
Class); PendingIntent restartServiceIntent = PendingIntent. GetService(DbUpdateService. This, 0, serviceIntent,0); AlarmManager alarms = (AlarmManager)getSystemService(ALARM_SERVICE); // cancel previous alarm alarms.
Cancel(restartServiceIntent); // schedule alarm for today + 1 day Calendar calendar = Calendar.getInstance(); calendar. Add(Calendar. DATE, 1); // schedule the alarm alarms.
Set(AlarmManager. RTC_WAKEUP, calendar.getTimeInMillis(), restartServiceIntent); return Service. START_STICKY; } } To start your service at boot time use this : import android.content.
BroadcastReceiver; import android.content. Context; import android.content. Intent; public class serviceAutoLauncher extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { Intent serviceIntent = new Intent(context,DbUpdateService.
Class); context. StartService(serviceIntent); } } Finally add this to your manifest to schedule your serviceAutoLauncher to be launched at each boot.
It depends on how you start the service. If you start it when your Activity is opened, then call stopService in your Activities onDestroy().
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.