简体   繁体   English

同步和异步请求Java Android

[英]sync and async request java android

I'm using geocoder which makes a sync request. 我正在使用发出同步请求的地址解析器。 I'm also making an async request to another service on another thread. 我还在向另一个线程上的另一个服务发出异步请求。 I need both results inorder to procede to the next step in my android app. 我需要两个结果才能继续执行我的android应用程序中的下一步。 What is the proper way to make sure both results are returned before moving on? 确保在继续进行之前都返回两个结果的正确方法是什么?

You can put the sync request in the doInBackground() method of your AsyncTask. 您可以将同步请求放入AsyncTask的doInBackground()方法中。 And handle the result in postExecute(). 并在postExecute()中处理结果。

Just wondering: your sync request won't freeze the UI thread? 只是想知道:您的同步请求不会冻结UI线程?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM