问题
I know it may seems to dumb question and there are lots of such questions but I have problems but I can't figure it out what does errors in log means. I know these http methods are deprecated and I should replace them, but I want to get response now. This is my code:
try
{
response = httpClient.execute(httpRequest);
responseCode = response.getStatusLine().getStatusCode();
responsePhrase = response.getStatusLine().getReasonPhrase();
HttpEntity responseEntity = response.getEntity();
if(responseEntity != null)
{
InputStream is = responseEntity.getContent();
responseString = convertStreamToString(is);
try
{
is.close();
} catch (Exception ignored) { }
}
else
return "";
}
catch (IOException e)
{
onError(e);
}
The codes goes to catch block when it tries to run httpClient.execute
and the e
object is null. This is log:
10-17 18:07:19.404 21766-21766/? E/Mms/ipmsg/compose﹕ saveIpMessageDraft(): mIpMessageDraft is null!
java.lang.Exception
at com.android.mms.ui.ComposeMessageActivity.saveIpMessageDraft(ComposeMessageActivity.java:13622)
at com.android.mms.ui.ComposeMessageActivity.onSaveInstanceState(ComposeMessageActivity.java:3870)
at android.app.Activity.performSaveInstanceState(Activity.java:1147)
at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1291)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3336)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3402)
at android.app.ActivityThread.access$900(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1400)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5391)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
I couldn't figure it out what errors are. I searched through web I couldn't find anything about saveIpMessageDraft
or mIpMessageDraft
. What is wrong with my code?
来源:https://stackoverflow.com/questions/33188052/error-on-executing-http-request-in-android