android - I cant make my new thread to function -
IM is actually new to Android and I need to send my current coordinates to my app on my webpad, get it To do this, I have a new thread, but the thread is not doing anything in the Magic SendQueryString () function supost is my code:
Public zero transfers (location location) on @Override {// marker draw, if destination location is not set to Latitude = location.getLat Itude (); Longitude = location.gateLong (); If (mMarkerPoints.size () & lt; 2) {mLatitude = location.getLatitude (); Mg = location.gateLong (); Late long point = new letting (mllid, lilgate); MGoogleMap.moveCamera (CameraUpdateFactory.newLatLng (dot)); MGoogleMap.animateCamera (CameraUpdateFactory.zoomTo (18)); DrawMarker (point); } String text = "my current latitude =" + latitude + "longitude =" + longitude; Thread trd = new thread (new runlevel) {@Override Public Zero (run) {tryQueryString ()}} Hold (Throws e) {e.printStackTrace ();}}}); Trd.start (); } Public Zero SendQueryString () {string = url = "http://sistemamedicointegrado.azurewebsites.net/Home/Ubicacion?latitud=" + latitude + "& longitud =" + longitude + "& id = 4"; Try {HTTP Client Client = New DefaultHttpClient (); HttpGet httpget = New HttpGet (url); Client.execute (httpget); } Hold (exception pre) {}} @Override Public Zero onProviderDisabled (String Provider) {// TODO Automatic Created Method Stub} @Override Public Zero onProviderEnabled (String Provider) {// TODO Automatic Created Method Stub} @Override Public Zero;} {}}
< P> Toast displaying will not work in the thread UI can be updated only on Yuri thread You
SendQueryString ();
Run the method in the thread
then you see SendQueryString ()
in
Toast.makeText ( GetApplicationContext (), "YESS", Toast .LENGTH_SHORT). Show (); Instead of
that is incorrect
threads
you can use asynctask
where you can override On the PreExecute
, onPostExecute
and onProgressUpdate
and update the UI. You can work your background in doInBackground
.
Comments
Post a Comment