onStartCommand NullPointerException

@Override
public int onStartCommand(Intent intent, int flags, int startId) 
{
isNeedUpload = intent.getBooleanExtra("isNeedUpload", false); 
if(isNeedUpload){
new UpLoadAsyncTask().execute();
}
return START_STICKY;

}


onStartCommand的时候爆空指针

还有提示:Service crashed 2 times, stopping: ServiceRecord{45931bc8 u。。。。。。。

还有提示:Crashing app skipping ANR: ProcessRecord{4525a240 16761:com.javgame.app.BackService/u0a10189} Executing service。。。。。



原因就是:START_STICKY的时候 intent不保证不为null,所以要加一下判断

或者 return super.onStartCommand(intent, Service.START_REDELIVER_INTENT, startId); 

部分参考: http://hold-on.iteye.com/blog/2024926

你可能感兴趣的:(onStartCommand NullPointerException)