AndroidHttpClient Nullpointerexception calling android.net.http.AndroidHttpClient.isMmsRequest

A customer has reported a strange error. When doing a normal AndroidHttpClient.execute() in an AsyncTask, the app crashes and he gets the following stack trace

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
at java.util.concurrent.FutureTask.run(FutureTask.java:239)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.NullPointerException
at android.net.http.AndroidHttpClient.isMmsRequest(AndroidHttpClient.java:257)
at android.net.http.AndroidHttpClient.checkMmsSendPermission(AndroidHttpClient.java:290)
at android.net.http.AndroidHttpClient.execute(AndroidHttpClient.java:296)
at com.xxx.xxx.MyClass$MyHandler.doWork(MyClass.java:325)
at  com.xxx.xxx.NetworkRequestHandler$AsyncTaskForRequestHandler.doInBackground(NetworkRequestHandler.java:532)
at com.xxx.xxx.utils.network.NetworkRequestHandler$AsyncTaskForRequestHandler.doInBackground(NetworkRequestHandler.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
... 3 more

Why is it calling checkMMSSendPermission and isSmsRequest? We are not using MMS and SMS at all, and the application do not have those permissions, which I guess is why it crashes. This works for all other 99.9% of our users.

Code looks like this

AndroidHttpClient client = AndroidHttpClient.newInstance(null);
        InputStream inputStream = null;
        try
        {
            HttpPost request = new HttpPost(urlString);
            prepareURLRequest(request);
            HttpResponse response = client.execute(request);
            mResultStatus = response.getStatusLine().getStatusCode();
            inputStream = response.getEntity().getContent();
...

Any help would be welcome

Update

This seems to be only affecting Sony Xperia Z, Z1 and ZR phones. Apparently the problems started to occur after receiving the update to Android 4.3. No one with those phones can use our app but for all else, it works.

Answers


Not sure why it's making calls to MMS and SMS methods but try doing this:

DefaultHttpClient client = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
try {
    HttpResponse execute = client.execute(httpPost);
    InputStream content = execute.getEntity().getContent();

This should work without any crashes.


Need Your Help

PHP and JQuery Button trigger not working

php jquery mysql button

Im currently new to PHP and JQuery after having using ASP.Net and C Sharp for the 2 years. I have this major problem in which i require some assistance in.

asp.net mvc post model and specify hour

jquery asp.net asp.net-mvc datetime

Hi I ahve a model and it has Datetime typed property. When I post the form the hour of the date property hour should be 23:59. Which way is make sense.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.