android - application may be doing too much work on main thread even after using a different thread -


hello new android , following yamba application posts , status twitter. working fine before added new part.

i used different thread perform post. once run project, logcat says"application may doing work on main thread".when type in status,"thread exiting uncaught exception",due nullpointexception in doinbackground method.

anyone can me??i have registered twitter account make sure not null.but alot answer!!

    public class mainactivity extends activity implements onclicklistener,textwatcher     {     private static final string tag="statusactivity";     edittext edittext;     button buttonupdate;     textview textcount;     private yambaapplication yamba;   //constructor      @override   public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);  edittext=(edittext) findviewbyid(r.id.edittext); buttonupdate=(button) findviewbyid(r.id.buttonupdate); textcount=(textview) findviewbyid(r.id.textcount); textcount.settext(integer.tostring(140)); textcount.settextcolor(color.green);  buttonupdate.setonclicklistener(this); edittext.addtextchangedlistener(this); this.yamba=(yambaapplication)getapplication(); }          //main task of posting, 3 method of asynctask class posttotwitter extends asynctask<string,integer,string> {     @override     protected string doinbackground(string...statuses)     {         try{              twitter.status status=yamba.gettwitter().updatestatus(statuses[0]);              return status.text;         }         catch(twitterexception e){             log.e(tag, e.tostring());             e.printstacktrace();             return "failed post";         }     } 

there task in yamba application java:

    public synchronized twitter gettwitter(){     if(twitter==null)     {         string username,password,apiroot;         username=prefs.getstring("username", "");         password=prefs.getstring("passord", "");         apiroot=prefs.getstring("apiroot", "http://yamba.marakana.com/api");       if ( !textutils.isempty(username) && !textutils.isempty(password) && !textutils.isempty(apiroot) )          {             twitter= new twitter(username,password);              twitter.setapirooturl(apiroot);           }      }     return this.twitter;   }  

don't blocking operations in main loop serves ui. includes things making requests remote system, twitter , yamba in case. while seems have been moved different thread, still blocking yamba interface while making request there, blocks other uses, too.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -