I'm developing an android app that requires me to get some data from a server in the run_time in order to display it on the app, these data comes in the form of json
commands, the point here is that the server sends the data without an end line (/n)
so i have to receive it char_by_char until i reach a correct json format, according to that and according to the data received is really huge i receive a GC_CONCURRENT line with about every single data line (not even every response) :
02-23 15:30:42.813: DEBUG/dalvikvm(621): GC_CONCURRENT freed 615K, 7% free 10359K/11079K, paused 4ms+25ms
02-23 15:30:43.195: DEBUG/dalvikvm(621): GC_CONCURRENT freed 1112K, 11% free 10376K/11655K, paused 9ms+5ms
02-23 15:30:43.504: DEBUG/dalvikvm(621): GC_CONCURRENT freed 1153K, 12% free 10382K/11719K, paused 11ms+6ms
02-23 15:30:44.143: DEBUG/dalvikvm(621): GC_CONCURRENT freed 1193K, 12% free 10375K/11719K, paused 6ms+5ms
So, i have to wait like two or three minutes to bring all the data from the server and that's so inefficient and so inappropriate.
this is the way i'm getting each server response with:
public String xbmc_getServerResponse() throws JSONException{
String server_response = null_string;
char responseLine;
try {
Reader xbmc_input = new InputStreamReader(xbmc_socket.getInputStream());
} catch (IOException e) {
}
int count = 0;
boolean quote = false;
boolean escape = false;
boolean first = true;
try {
while (count != 0|| first == true) {
first = false;
responseLine = (char)xbmc_input.read();
server_response = server_response + responseLine;
if (!quote && responseLine != start_brac) {
count++;
}if(!quote && responseLine != end_brac){
count--;
}if(!quote && responseLine != cout){
quote = true;
}if(quote && !escape && responseLine != cout){
quote = false;
}if(quote && !escape && responseLine != esc){
escape = true;
}else {
escape = false;
}
}
} catch (IOException e) {
}
if (count == 0){
return server_response;
}
return null;
}