In the last Article you saw how to call an IntentService. Then you printed a Log statement in the background thread, once the service completed.
If you want to display a message in the Main Thread then you can use a Handler. A Handler allows you to access the Main Thread once the service is complete.
Here is the sample source code to achieve this.
@Override protected void onHandleIntent(Intent intent) { Log.v(TAG, "In onHandleIntent. Message will be printed after 10sec"); if (intent != null) { synchronized (this){ try { wait(10000); } catch (InterruptedException e) { e.printStackTrace(); } Log.v(TAG, "Service started"); mHandler.post(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), "Service Completed" , Toast.LENGTH_SHORT).show(); } }); } } }
Complete source code is available here.