you can use intentService to communicate with mainThread
here is a basic examples of intentservice and service
http://mobile.tutsplus.com/tutorials/android/android-fundamentals-intentservice-basics/
service example
http://www.vogella.com/articles/AndroidServices/article.html
here is an official document
http://developer.android.com/reference/android/app/IntentService.html