Android : app forceclose while running in background

on Wednesday, August 13, 2014


In my android app i have one service which calls some webservices after a fix interval. App is running perfectly in foreground and refresh data,but when user exit from app and use some other app then my app force close after many times. Why this app force close while running in background.


Code that i was using for start service -



msgIntent = new Intent(mContext, MyBackgroundService.class);
startService(msgIntent);


and inside onDestroy() of my main activity i have following code to stop service-



if(msgIntent!=null){
stopService(msgIntent);
}


background service call some async task and each aync task onPostExecute() method execute some insert statement in database.


i am not geting why this force close occure.


Please give your comments.


Thanks in advance.


0 comments:

Post a Comment