Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Java中的异步POST请求_Java_Android_Post_Asynchronous_Http Post - Fatal编程技术网

Android Java中的异步POST请求

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:/

使用Java for Android,我该怎么做?

看看AsyncTask。在while循环中反复检查另一个线程的结果不是一个好主意


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(); }