Android hander Threading usage

Source: Internet
Author: User

@Overridepublic void OnClick (View v) {lsh = "576"; startdate = Setstart_date.gettext (). toString (); enddate = Setend_ Date.gettext (). toString (); btnlogincontext = V.getcontext (); Handlerthread handlerthread = new Handlerthread ("Handlerthread"); Handlerthread.start ();//start thread MyHandler MyHandler = New MyHandler (Handlerthread.getlooper ());//Build Message Queue Processor (new thread) Message msg = Myhandler.obtainmessage ();//Bind Custom Processor bundle bundle = new Bundle (); Bundle.putstring ("StartDate", StartDate); Bundle.putstring ("EndDate", EndDate); Bundle.putstring ("LSH", LSH); Msg.setdata (bundle); Msg.sendtotarget ();} @Overridepublic void Handlemessage (Message msg) {try {super.handlemessage (msg); Bundle bundle = Msg.getdata (); if (bundle = = null) return; String result = ""; StringBuilder str = new StringBuilder (); Str.append ("<condition><ksrqsj>" + bundle.get ("StartDate"). ToString () + "</ksrqsj>"), Str.append ("<jsrqsj>" + bundle.get ("EndDate"). ToString () + "</jsrqsj>"); Str.append ("<lsh>" + bundle.get ("LSH")). ToString () + "</lsh></condition>"); Requireparams params = new Requireparams ();p arams.setmethodname ("Getnursetableinfopag"); Webserviceinvoker invoker = new Webserviceinvoker () invoker.setparams (params);//Set parameter Soapobject request = Invoker.getrequestinstance (); Request.addproperty ("Condition", str.tostring ()); Request.addproperty ("RecBegin", 0) ; Request.addproperty ("recend"); result = Invoker.invokews (request). GetProperty (0). toString (); if (result.indexof ("error") >= 0) {showmydialog (btnlogincontext, result); return;} else {list<map<string, object>>  Mynurseinfos = Null;mynurseinfos = Nurseinfo.getnurseinfo (result, "UTF-8");//query succeeds Intent intent = new intent ();        Bundle Mybundle = new bundle ();        Final serializablemaplist mymap=new serializablemaplist ();                Mymap.setmap (Mynurseinfos); Mybundle.putserializable ("Listdata", MyMap);                Intent.putextras (Mybundle);                  Intent.setclass (Getactivity (), nursingpagequery.class); StArtactivity (Intent); }} catch (Exception e) {log.e (TAG, log.getstacktracestring (e)); Toast.maketext (Getactivity (), "error:" + log.getstacktracestring (e), Toast.length_long). Show ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.