Вот такой лог:
D/CONNECT:: START
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.run18.flirtodrom, PID: 5385
java.lang.NullPointerException: println needs a message
at android.util.Log.println_native(Native Method)
at android.util.Log.d(Log.java:143)
at com.example.run18.flirtodrom.PlaceItem$GetProductDetails$1.run(PlaceItem.java:107)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
А вот такой код:
class GetProductDetails extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(PlaceItem.this);
pDialog.setMessage("Loading product details. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
protected String doInBackground(String[] params) {
runOnUiThread(new Runnable() {
public void run() {
Log.d("CONNECT: ", "START");
try {
//GET
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(url_db + "?action=get_place_by_id&id=" + pid).build();
Response response = client.newCall(request).execute();
String result = response.body().string();
Log.d("CONNECT: ", "OK");
/*JSONArray productObj = new JSONArray(result);
try {
if (1 == 1) {
JSONObject product = productObj.getJSONObject(0);
txtName = (EditText) findViewById(R.id.inputName);
txtPrice = (EditText) findViewById(R.id.inputPrice);
txtDesc = (EditText) findViewById(R.id.inputDesc);
txtName.setText(product.getString(TAG_NAME));
txtPrice.setText(product.getString(TAG_PRICE));
txtDesc.setText(product.getString(TAG_DESCRIPTION));
} else {
// продукт с pid не найден
}
} catch (JSONException e) {
e.printStackTrace();
}*/
} catch (Exception e) {
Log.d("CONNECT: ", e.getMessage());
}
}
});
return null;
}
protected void onPostExecute(String file_url) {
pDialog.dismiss();
}
}
Пробовал комментить execute() - не выкидывает. Сервер данные отдает без ошибок. На предыдущем активити тоже есть аналогичный вызов okhttp, он проходит без ошибок.