Asyntask parallel run error in android

i have some code inside an android service, a timer that run some Asyntasks in every 3 seconds. but sometimes i get this error: 03-21 08:56:48.928: E/AndroidRuntime(26870): FATAL EXCEPTION: AsyncTask #3 03-21 08:56:48.928: E/AndroidRuntime(26870): java.lang.RuntimeException: An error occured while executing doInBackground() 03-21 08:56:48.928: E/AndroidRuntime(26870): at android.os.AsyncTask$3.done(AsyncTask.java:299) 03-21 08:56:48.928: E/AndroidRuntime(26870): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273) 03-21 08:56:48.928: E/AndroidRuntime(26870): at java.util.concurrent.FutureTask.setException(FutureTask.java:124) 03-21 08:56:48.928: E/AndroidRuntime(26870): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307) 03-21 08:56:48.928: E/AndroidRuntime(26870): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 03-21 08:56:48.928: E/AndroidRuntime(26870): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 03-21 08:56:48.928: E/AndroidRuntime(26870): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 03-21 08:56:48.928: E/AndroidRuntime(26870): at java.lang.Thread.run(Thread.java:856) 03-21 08:56:48.928: E/AndroidRuntime(26870): Caused by: java.lang.NullPointerException 03-21 08:56:48.928: E/AndroidRuntime(26870): at Dic.proj.pkg.notifService$check_last_asyn.doInBackground(notifService.java:251) 03-21 08:56:48.928: E/AndroidRuntime(26870): at Dic.proj.pkg.notifService$check_last_asyn.doInBackground(notifService.java:1) 03-21 08:56:48.928: E/AndroidRuntime(26870): at android.os.AsyncTask$2.call(AsyncTask.java:287) 03-21 08:56:48.928: E/AndroidRuntime(26870): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 03-21 08:56:48.928: E/AndroidRuntime(26870): ... 4 more i dont know why. but i have a guess. my service starts from main activity by this code: Intent service = new Intent(DictionaryActivity.this, notifService.class); DictionaryActivity.this.startService(service); i guess first time i start my service by opening main activity. then second time when im going to main activity, service starts again and my Asyntasks runs parallel and this cause this error... is there any way to check if service started already, then don't start it again? how i can solve my problem?
You have a NullPointerException -- one of your members isn't assigned. Step through doInBackgound to find which one, or just double-click on the logcat entry.

以上就是Asyntask parallel run error in android的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏