Q:

AsyncTask with intent service (w AlarmManager)

I have finished building an android weather application.  It uses AsyncTask to get weather from an api and updates UI in onPostExecute() by calling notifyDataSetChanged() on the adapter. 
Now I would also like to create a background service/task etc.  I am aware of AlarmManager.  I would like to know, what should be used in conjunction with an AlarmManager to trigger the AsyncTask.  My concern and reason for this question is my AsyncTask is also updating the UI.  However if any background service call the AsyncTask, there is no UI in the foreground as app is not running currently.  Will it result in a crash? 
UPDATE
In my main activity I call this method to initiate my alarm manager
 public void scheduleAlarm() {
    // Construct an intent that will execute the AlarmReceiver
    Intent intent = new Intent(getApplicationContext(), AlarmReceiver.class);
    // Create a PendingIntent to be triggered when the alarm goes off
    final PendingIntent pIntent = PendingIntent.getBroadcast(this, AlarmReceiver. REQUEST_CODE,
            intent, PendingIntent. FLAG_UPDATE_CURRENT);
    // Setup periodic alarm every 5 seconds
    long firstMillis = System.currentTimeMillis(); // first run of alarm is immediate
    int intervalMillis = 10000; // 5 seconds
    AlarmManager alarm = (AlarmManager) this.getSystemService(Context. ALARM_SERVICE);
    alarm.setInexactRepeating(AlarmManager. RTC_WAKEUP, firstMillis, intervalMillis, pIntent);
}

Alarm manager implementation:
 @Override
public void onReceive(Context context, Intent intent) {
    Intent i = new Intent(context, WeatherIntentService.class);
    i.putExtra("foo", "bar");
    context.startService(i);
}

Intent service implementation
    @Override
protected void onHandleIntent(Intent intent) {
    // Do the task here
    Log.i("MyTestService", "Service running");
}

I am confused as to how to start the async task.  As my async task is dependant on sharedpreferences and also location received from gms etc.  Please guide me to the right path. 

A:

Since there is no UI, place your Asynctask in a Service and then store your data in SQLite so that the moment you open the app >> you only need to fetch it from the database. 
Here is an example flow

Alarm Manager will tell the Service to Execute the Asynctask
Asynctask will gather information from the server or your API
The gathered information/data should be stored in SQL
When opening the App, ask first the database for the data and update the UI. 
Do your usual app routine

