我通过 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。我在这里想念什么?
我尝试了其他方法,但这对朋友有用。所以它应该工作。