私はこのコードを持っています、
CALL および WAIT することになっている
AsyncTask "getCreator" .
private String getcreator(String id) {
String creator = null;
Log.e("","entro proprio in getcreator "+ id);
if (id != null) {
String srt = "";
getCreator chn = new getCreator();
chn.execute(id, null, null);
try {
srt = chn.get();
Log.e("","predodo qulacosa da getcreator");
} catch (Exception e) {
Log.e("","exceltion in getcreator");
e.printStackTrace();
}
JSONObject jObject = null;
try {
jObject = new JSONObject(srt);
creator = jObject.getString("name");
} catch (JSONException e) {
// Json parse error usually
}
}
return creator;
}
しかし、AsyncTask getCreatorは決して doinbackground() を実行しません!!!
public class getCreator extends AsyncTask<String, String, String> {
public String res;
@Override
protected void onProgressUpdate(String... progress) {
}
@Override
protected void onPostExecute(String result) {
}
@Override
protected String doInBackground(String... symbol) {
String result = "";
Log.e("","entro in getcreator"+ symbol[0]);
DefaultHttpClient client = new DefaultHttpClient();
HttpParams httpParameters = new BasicHttpParams();
// Set the timeout in milliseconds until a connection is
// established.
// The default value is zero, that means the timeout is not
// used.
int timeoutConnection = 3000;
HttpConnectionParams.setConnectionTimeout(httpParameters,
timeoutConnection);
// Set the default socket timeout (SO_TIMEOUT)
// in milliseconds which is the timeout for waiting for data.
int timeoutSocket = 5000;
HttpConnectionParams
.setSoTimeout(httpParameters, timeoutSocket);
client.setParams(httpParameters);
String srt = "";
String url = "http://graph.facebook.com/".concat(symbol[0]);
HttpGet getMethod = new HttpGet(url);
try {
ResponseHandler<String> responseHandler = new BasicResponseHandler();
srt = client.execute(getMethod, responseHandler);
result = srt;
} catch (Throwable t) {
// Toast.makeText(getApplicationContext(),
// "Internet Problem", Toast.LENGTH_SHORT).show();
}
Log.e("","esco in getcreator");
return result;
}
}
助けてください!!!!
正確に言うと: doInBackground() は実行されません....
メソッド private String getcreator(String id) が定期的に呼び出され、そのログが生成されます。
ヘルプ!!!