-1

我通过 new CreateNewThread().execute(); 执行

class CreateNewThread extends AsyncTask<String, String, String> {

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(CreateThread.this);
        pDialog.setMessage("Creating Thread..");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();
    }

    protected String doInBackground(String... args) {

        tittel = inputTitle.getText().toString();
        tekst = inputText.getText().toString();

        if (!tittel.equals("") && !tekst.equals("")) {
            try {
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(
                        "http://.../createthread?title="
                                + tittel + "&text=" + tekst);
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity entity = response.getEntity();
                InputStream is = entity.getContent();
                BufferedReader in = new BufferedReader(new InputStreamReader(
                        is,"iso-8859-1"));
                System.out.println(tittel);
                System.out.println(tekst);
                System.out.println(in);
                String line;

                while ((line = in.readLine()) != null) {
                    JSONObject jo = new JSONObject(line);
                    System.out.println(jo.getString("svar"));
                }
            } catch (Exception e) {
                System.out.println("catchgreiene" + e);
            }

        } 
        else {
            System.out.println();
        }
        return null;
    }

    protected void onPostExecute(String file_url) {
        pDialog.dismiss();
    }

}

我只是想运行一个网址。php 文件在浏览器中运行。这是 2.2 Froyo。我在这里想念什么?

我尝试了其他方法,但这对朋友有用。所以它应该工作。

4

1 回答 1

-1

我不知道这是否是问题所在,但你永远不应该在 android 中执行 System.out.println。改用 Log.w("tag","key") !

于 2012-11-22T15:42:06.217 回答