i have written asynctask extended class reads data internet. although code working fine in emulator (gb) i-e; returning data internet when run code on phone (jb), doesn't return anything. code creating following exceptions in logcat of emualtor. here code:
new usercred().execute(usercredentials); public class usercred extends asynctask<string[], string, string> { @override protected string doinbackground(string[]... arg0) { ...... startactivity(intent); return null; // because not returning anythign } }
logcat:
07-15 21:49:56.768: w/system.err(1542): java.lang.runtimeexception: can't create handler inside thread has not called looper.prepare() 07-15 21:49:56.768: w/system.err(1542): @ android.os.handler.<init>(handler.java:121) 07-15 21:49:56.768: w/system.err(1542): @ android.widget.toast.<init>(toast.java:68) 07-15 21:49:56.768: w/system.err(1542): @ android.widget.toast.maketext(toast.java:231) 07-15 21:49:56.768: w/system.err(1542): @ com.umer.androiduetproject.loginaccount.sendcredentialsforcheckingonline(loginaccount.java:71) 07-15 21:49:56.768: w/system.err(1542): @ com.umer.androiduetproject.loginaccount$usercred.doinbackground(loginaccount.java:124) 07-15 21:49:56.768: w/system.err(1542): @ com.umer.androiduetproject.loginaccount$usercred.doinbackground(loginaccount.java:1) 07-15 21:49:56.768: w/system.err(1542): @ android.os.asynctask$2.call(asynctask.java:185) 07-15 21:49:56.768: w/system.err(1542): @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:306) 07-15 21:49:56.768: w/system.err(1542): @ java.util.concurrent.futuretask.run(futuretask.java:138) 07-15 21:49:56.768: w/system.err(1542): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1088) 07-15 21:49:56.768: w/system.err(1542): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:581) 07-15 21:49:56.768: w/system.err(1542): @ java.lang.thread.run(thread.java:1019) 07-15 21:50:24.169: w/system.err(1542): java.lang.runtimeexception: can't create handler inside thread has not called looper.prepare() 07-15 21:50:24.169: w/system.err(1542): @ android.os.handler.<init>(handler.java:121) 07-15 21:50:24.169: w/system.err(1542): @ android.widget.toast.<init>(toast.java:68) 07-15 21:50:24.169: w/system.err(1542): @ android.widget.toast.maketext(toast.java:231) 07-15 21:50:24.169: w/system.err(1542): @ com.umer.androiduetproject.loginaccount.sendcredentialsforcheckingonline(loginaccount.java:71) 07-15 21:50:24.169: w/system.err(1542): @ com.umer.androiduetproject.loginaccount$usercred.doinbackground(loginaccount.java:124) 07-15 21:50:24.169: w/system.err(1542): @ com.umer.androiduetproject.loginaccount$usercred.doinbackground(loginaccount.java:1) 07-15 21:50:24.169: w/system.err(1542): @ android.os.asynctask$2.call(asynctask.java:185) 07-15 21:50:24.179: w/system.err(1542): @ java.util.concurrent.futuretask$sync.innerrun(futuretask.java:306) 07-15 21:50:24.179: w/system.err(1542): @ java.util.concurrent.futuretask.run(futuretask.java:138) 07-15 21:50:24.179: w/system.err(1542): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1088) 07-15 21:50:24.179: w/system.err(1542): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:581) 07-15 21:50:24.179: w/system.err(1542): @ java.lang.thread.run(thread.java:1019)
jb logcat:
07-15 18:51:36.378: e/activitythread(1466): service com.android.exchange.exchangeservice has leaked serviceconnection com.android.emailcommon.service.serviceproxy$proxyconnection@b50afe10 bound here 07-15 18:51:36.378: e/activitythread(1466): android.app.serviceconnectionleaked: service com.android.exchange.exchangeservice has leaked serviceconnection com.android.emailcommon.service.serviceproxy$proxyconnection@b50afe10 bound here 07-15 18:51:36.378: e/activitythread(1466): @ android.app.loadedapk$servicedispatcher.<init>(loadedapk.java:969) 07-15 18:51:36.378: e/activitythread(1466): @ android.app.loadedapk.getservicedispatcher(loadedapk.java:863) 07-15 18:51:36.378: e/activitythread(1466): @ android.app.contextimpl.bindservice(contextimpl.java:1418) 07-15 18:51:36.378: e/activitythread(1466): @ android.app.contextimpl.bindservice(contextimpl.java:1407) 07-15 18:51:36.378: e/activitythread(1466): @ android.content.contextwrapper.bindservice(contextwrapper.java:473) 07-15 18:51:36.378: e/activitythread(1466): @ com.android.emailcommon.service.serviceproxy.settask(serviceproxy.java:157) 07-15 18:51:36.378: e/activitythread(1466): @ com.android.emailcommon.service.serviceproxy.settask(serviceproxy.java:145) 07-15 18:51:36.378: e/activitythread(1466): @ com.android.emailcommon.service.serviceproxy.test(serviceproxy.java:191) 07-15 18:51:36.378: e/activitythread(1466): @ com.android.exchange.exchangeservice$7.run(exchangeservice.java:1850) 07-15 18:51:36.378: e/activitythread(1466): @ com.android.emailcommon.utility.utility$2.doinbackground(utility.java:551) 07-15 18:51:36.378: e/activitythread(1466): @ com.android.emailcommon.utility.utility$2.doinbackground(utility.java:549) 07-15 18:51:36.378: e/activitythread(1466): @ android.os.asynctask$2.call(asynctask.java:287) 07-15 18:51:36.378: e/activitythread(1466): @ java.util.concurrent.futuretask.run(futuretask.java:234) 07-15 18:51:36.378: e/activitythread(1466): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1080) 07-15 18:51:36.378: e/activitythread(1466): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:573) 07-15 18:51:36.378: e/activitythread(1466): @ java.lang.thread.run(thread.java:856) 07-15 18:51:36.378: e/strictmode(1466): null 07-15 18:51:36.378: e/strictmode(1466): android.app.serviceconnectionleaked: service com.android.exchange.exchangeservice has leaked serviceconnection com.android.emailcommon.service.serviceproxy$proxyconnection@b50afe10 bound here 07-15 18:51:36.378: e/strictmode(1466): @ android.app.loadedapk$servicedispatcher.<init>(loadedapk.java:969) 07-15 18:51:36.378: e/strictmode(1466): @ android.app.loadedapk.getservicedispatcher(loadedapk.java:863) 07-15 18:51:36.378: e/strictmode(1466): @ android.app.contextimpl.bindservice(contextimpl.java:1418) 07-15 18:51:36.378: e/strictmode(1466): @ android.app.contextimpl.bindservice(contextimpl.java:1407) 07-15 18:51:36.378: e/strictmode(1466): @ android.content.contextwrapper.bindservice(contextwrapper.java:473) 07-15 18:51:36.378: e/strictmode(1466): @ com.android.emailcommon.service.serviceproxy.settask(serviceproxy.java:157) 07-15 18:51:36.378: e/strictmode(1466): @ com.android.emailcommon.service.serviceproxy.settask(serviceproxy.java:145) 07-15 18:51:36.378: e/strictmode(1466): @ com.android.emailcommon.service.serviceproxy.test(serviceproxy.java:191) 07-15 18:51:36.378: e/strictmode(1466): @ com.android.exchange.exchangeservice$7.run(exchangeservice.java:1850) 07-15 18:51:36.378: e/strictmode(1466): @ com.android.emailcommon.utility.utility$2.doinbackground(utility.java:551) 07-15 18:51:36.378: e/strictmode(1466): @ com.android.emailcommon.utility.utility$2.doinbackground(utility.java:549) 07-15 18:51:36.378: e/strictmode(1466): @ android.os.asynctask$2.call(asynctask.java:287) 07-15 18:51:36.378: e/strictmode(1466): @ java.util.concurrent.futuretask.run(futuretask.java:234)
07-15 18:51:36.378: e/strictmode(1466): @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1080) 07-15 18:51:36.378: e/strictmode(1466): @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:573) 07-15 18:51:36.378: e/strictmode(1466): @ java.lang.thread.run(thread.java:856)
regards
you're trying restricted things on background thread. jellybean has gotten more strict enforcing rule, , gingerbread wasn't. why there not issue on emulator broke on device. move startactivity(intent) , other ui interactive code onpostexecute instead, or use handler post messages main thread asynctask. want background , potentially blocking operations in asynctask. hope helps
edit: turns out trying show toast in doinbackground(). not allowed, you're trying interact views meant touched on main thread. remove toast, , use log instead or use handler instance show it.
Comments
Post a Comment