Android Java中的异步POST请求
使用Java for Android,我该怎么做?看看AsyncTask。在while循环中反复检查另一个线程的结果不是一个好主意Android Java中的异步POST请求,java,android,post,asynchronous,http-post,Java,Android,Post,Asynchronous,Http Post,使用Java for Android,我该怎么做?看看AsyncTask。在while循环中反复检查另一个线程的结果不是一个好主意 mmh。。关于如何在我的案例中使用AsyncTask的一个实际示例?我提供的链接中的示例应该让您了解如何实现。在doInBackground()中,您将执行POST,在onPostExecute()中,您将检查结果。如果答案对你有帮助,请接受。 public void btnWeb_Click(View view){ String url="http:/
mmh。。关于如何在我的案例中使用AsyncTask的一个实际示例?我提供的链接中的示例应该让您了解如何实现。在doInBackground()中,您将执行POST,在onPostExecute()中,您将检查结果。如果答案对你有帮助,请接受。
public void btnWeb_Click(View view){
String url="http://localhost/test/index.php";
List<NameValuePair> dict = new ArrayList<NameValuePair>();
dict.add(new BasicNameValuePair("url",url));
dict.add(new BasicNameValuePair("id", "3"));
PostReq postreq= new PostReq();
postreq.execute(dict);
String result="";
while(result==""){ result= postreq.content;}
System.out.println(result); }
async void button_click() {
Dictionary<string, string> dict = new Dictionary<string, string>();
dict.Add("id", "3");
string url="http://localhost/test/index.php";
PostReq pr= new PostReq(url,dict);
String risposta = await pr.getRisposta(); }