stream.close();
}
Log.d(getClass().getName(),"HTTP Response: "+conn.getResponseCode()+" "+conn.getResponseMessage());
- final String message=conn.getResponseMessage();
+ String message=conn.getResponseMessage();
if(message==null && callback != null)
callback.onError(toNonNull(context.getString(no_response_returned_from_server)));
- else if(message != null && callback != null)
- callback.onResult(conn.getResponseCode(), message,
- toNonNull(conn.getInputStream()));
+ else if(message != null && callback != null){
+ if(message.charAt(message.length()-1) == ')')//message is (something)
+ message=message.substring(1, message.length()-1);
+ else
+ message=message.substring(message.indexOf(')')+2);
+ callback.onResult(conn.getResponseCode(), message, conn.getResponseCode() == 200 ? conn.getInputStream() : null);
+ }
conn.disconnect();
} catch (Exception e) {
e.printStackTrace();
import static ro.ieval.fonbot.Utils.toNonNull;
import java.io.InputStream;
+import org.eclipse.jdt.annotation.Nullable;
import org.json.JSONArray;
import org.json.JSONObject;
}
@Override
- public void onResult(final int responseCode, final String responseMessage, final InputStream inputStream) {
- if(responseCode!=200)
+ public void onResult(final int responseCode, final String responseMessage, final @Nullable InputStream inputStream) {
+ if(responseCode!=200 || inputStream==null)
return;
final Handler handler=new Handler(Looper.getMainLooper());