json parse error inside a Asyntask in android - java

I get this error "Sometimes" in my App, I use a Asyntask:
03-19 08:10:05.768: E/AndroidRuntime(280): FATAL EXCEPTION: main
03-19 08:10:05.768: E/AndroidRuntime(280): java.lang.NumberFormatException: unable to parse 'null' as integer
03-19 08:10:05.768: E/AndroidRuntime(280): at java.lang.Integer.parseInt(Integer.java:406)
03-19 08:10:05.768: E/AndroidRuntime(280): at java.lang.Integer.parseInt(Integer.java:382)
03-19 08:10:05.768: E/AndroidRuntime(280): at java.lang.Integer.valueOf(Integer.java:682)
03-19 08:10:05.768: E/AndroidRuntime(280): at Dic.proj.pkg.notifService$1$1$1$1.onPostExecute(notifService.java:76)
03-19 08:10:05.768: E/AndroidRuntime(280): at Dic.proj.pkg.notifService$1$1$1$1.onPostExecute(notifService.java:1)
03-19 08:10:05.768: E/AndroidRuntime(280): at android.os.AsyncTask.finish(AsyncTask.java:417)
03-19 08:10:05.768: E/AndroidRuntime(280): at android.os.AsyncTask.access$300(AsyncTask.java:127)
03-19 08:10:05.768: E/AndroidRuntime(280): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
03-19 08:10:05.768: E/AndroidRuntime(280): at android.os.Handler.dispatchMessage(Handler.java:99)
03-19 08:10:05.768: E/AndroidRuntime(280): at android.os.Looper.loop(Looper.java:123)
03-19 08:10:05.768: E/AndroidRuntime(280): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-19 08:10:05.768: E/AndroidRuntime(280): at java.lang.reflect.Method.invokeNative(Native Method)
03-19 08:10:05.768: E/AndroidRuntime(280): at java.lang.reflect.Method.invoke(Method.java:521)
03-19 08:10:05.768: E/AndroidRuntime(280): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-19 08:10:05.768: E/AndroidRuntime(280): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-19 08:10:05.768: E/AndroidRuntime(280): at dalvik.system.NativeStart.main(Native Method)
i call my Asyntask inside a timer. this is my my Asyntask:
// fetch new notifications
class fetch_last_asyn extends AsyncTask<Void, Integer, Boolean> {
#Override
protected Boolean doInBackground(Void... arg0) {
RestClient client = new RestClient(
"http://myaddress.org/api/get_last.php");
client.AddParam("last", String.valueOf(last_notif_no));
try {
client.Execute(RequestMethod.GET);
} catch (Exception e) {
e.printStackTrace();
}
String response = client.getResponse();
last_notifs = response.toString();
return true;
}
}
Inside my app I send my Asyntask result to parse to a code (parse_get_update), this is it:
public static String[][] parse_get_update(String jsonResponse) {
String[][] notifs = new String[3000][10];
try {
JSONArray jsonArray = new JSONArray(jsonResponse);
for (int index = 0; index < jsonArray.length(); index++) {
JSONObject json = jsonArray.getJSONObject(index);
// get name & id here
String id = json.getString("id");
String notifno = json.getString("notifno");
String title = json.getString("title");
String description = json.getString("description");
notifs[index][0] = id;
notifs[index][1] = notifno;
notifs[index][2] = title;
notifs[index][3] = description;
// notif_count++;
}
cnt2 = jsonArray.length();
} catch (JSONException e) {
e.printStackTrace();
}
return notifs;
}
Why do I get this error? What is NULL? I cant understand this.
I use ResClient for parse JSON. This error occures sometimes only, about 10% of times...
Thanks for your answers

In your postExecute() method, somewhere, you're parsing a String to Integer using this - Integer.parseInt(str);
Most of the times that str is a valid number, hence, its working. But those 10% of times, that str is probably missing or coming as an emtpy String from the JSON and hence, a null is passed to the Integer.parseInt(null), which is causing the java.lang.NumberFormatException.
Identify that piece of code, and put a null check for that, before parsing it to Integer.

The error means that you are trying to parse a string which has nothing in it. To demonstrate you have are doing like below.
String s = "";
int i = Integer.parseInt(s);
You need to have a condition like below so that it doesn't parse if the string is empty. You can even use try catch block as well.
if(s is not null) {
then do parse here
}
else {
assign a default value
}

This is happening due to you're parsing a String to Integer see this answer.

Related

unfortunately app closed error in android app when i debug the code

I have developed an app in android to find power shut down.When i run the app ,unfortunately closed once I debug the app.Here I got the error in doInbackground
My java code is here
private static final String URL = "http://livechennai.com/powershutdown_news_chennai.asp";
//private static final String URL = "http://livechennai.com/powercut_schedule.asp";
ProgressDialog mProgressDialog;
EditText filterItems;
ArrayAdapter<String> arrayAdapter;
protected String[] doInBackground(Void... params) {
ArrayList<String> hrefs=new ArrayList<String>();
try {
// Connect to website
Document document = Jsoup.connect(URL).get();
// Get the html document title
websiteTitle = document.title();
Elements table=document.select("#table13>tbody>tr>td>a[title]");
for(Element link:table){
hrefs.add(link.attr("abs:href"));
//int arraySize=hrefs.size();
//websiteDescription=link.attr("abs:href");
}
} catch (IOException e) {
e.printStackTrace();
}
//get the array list values
for(String s:hrefs)
{
websiteDescription=hrefs.get(0);
websiteDescription1=hrefs.get(1);
websiteDescription2=hrefs.get(2);
websiteDescription3=hrefs.get(3);
}
Below is the error log
06-09 23:17:10.284 17923-17937/com.example.poweralert.app E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
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 android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
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:838)
Caused by: java.lang.IllegalArgumentException: Must supply a valid URL
at org.jsoup.helper.Validate.notEmpty(Validate.java:102)
at org.jsoup.helper.HttpConnection.url(HttpConnection.java:60)
at org.jsoup.helper.HttpConnection.connect(HttpConnection.java:30)
at org.jsoup.Jsoup.connect(Jsoup.java:73)
at com.example.poweralert.app.PrimaryActivity$FetchWebsiteData.doInBackground(PrimaryActivity.java:144)
at com.example.poweralert.app.PrimaryActivity$FetchWebsiteData.doInBackground(PrimaryActivity.java:100)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
            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:838)
06-09 23:17:10.
How to solve this error/issue? It shows null in website description .
Looks like there is an error in URL connection. Are you not passing valid URL?
Caused by: java.lang.IllegalArgumentException: Must supply a valid URL

retriving stock quote with yahoo finance

i have this form with a button upon submit i retrieve stock info from yahoo finance api, and use it to display onto three textviews
the url i use
http://download.finance.yahoo.com/d/quotes.csv?s=goog&f=sl1p2
and my button event handler is
URL url;
try {
url = new URL("http://download.finance.yahoo.com/d/quotes.csv?s=goog&f=sl1p2");
InputStream stream = url.openStream();
BufferedInputStream bis = new BufferedInputStream(stream);
ByteArrayBuffer bab = new ByteArrayBuffer(50);
int current = 0;
while((current = bis.read()) != -1){
bab.append((byte) current);
}
String stockTxt = new String(bab.toByteArray());
String[] tokens = stockTxt.split(",");
String stockSymbol = tokens[0];
String stockPrice = tokens[1];
String stockChange = tokens[2];
String fstockSymbol = stockSymbol.substring(1, stockSymbol.length() -1);
String fstockChange = stockChange.substring(1, stockChange.length()-3);
symbolOut.setText(fstockSymbol);
priceOut.setText(stockPrice);
changeOut.setText(fstockChange);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
so what i noticed till the first line there seems to be no problem i.e url = new URL...,(even the bare http request done through browser, does return the info i need )
and my manifest entry looks like
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
below is the logcat output
05-02 18:36:32.804: D/AndroidRuntime(902): Shutting down VM
05-02 18:36:32.804: W/dalvikvm(902): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
05-02 18:36:33.113: E/AndroidRuntime(902): FATAL EXCEPTION: main
05-02 18:36:33.113: E/AndroidRuntime(902): android.os.NetworkOnMainThreadException
05-02 18:36:33.113: E/AndroidRuntime(902): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
05-02 18:36:33.113: E/AndroidRuntime(902): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
05-02 18:36:33.113: E/AndroidRuntime(902): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
05-02 18:36:33.113: E/AndroidRuntime(902): at java.net.InetAddress.getAllByName(InetAddress.java:220)
05-02 18:36:33.113: E/AndroidRuntime(902): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
so anybody knows where im going wrong
This is the key error in your LogCat message --> android.os.NetworkOnMainThreadException. You should move your network access to a background thread. You can use either an IntentService, AsynchTask, Handler, etc. to accomplish this.
Check out http://developer.android.com/training/articles/perf-anr.html for more information about why it is important to do network ops on a separate thread.

Android Freebase Query IOException

I am attempting a simple Freebase Query within Android, Eclipse. I believe the URL compiles correctly, as I can copy/paste the encoded URL, copy/paste it into a browser and it pulls up the correct result. The line HttpResponse httpResponse = httpClient.execute... is throwing an IOException.
JSONParser parser = new JSONParser();
String query = "{\"type\":\"/user/tsegaran/language/phrase\",\"id\":null,\"name\":\"Affidavit\",\"/user/tsegaran/language/phrase/translation\":[]}";
String testQuery = URLEncoder.encode(query, "UTF-8");
String testQuery1 = "https://www.googleapis.com/freebase/v1/mqlread?query=" + testQuery + "&key=" + API_KEY;
HttpClient httpClient = new DefaultHttpClient();
HttpResponse httpResponse = httpClient.execute(new HttpGet(testQuery1));
JSONObject response = (JSONObject)parser.parse(EntityUtils.toString(httpResponse.getEntity()));
String jsonResults = response.getString("result");
JSONObject object = (JSONObject) new JSONTokener(jsonResults).nextValue();
String name = object.getString("/user/tsegaran/language/phrase/translation");
...
Here is a better formatted version of my Stack Trace:
java.net.UnknownHostException: www.googleapis.com
java.net.InetAddress.lookupHostByName(InetAddress.java:506)
java.net.InetAddress.getAllByNameImpl(InetAddress.java:294)
java.net.InetAddress.getAllByName(InetAddress.java:256)
org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:359)
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
com.example.nworthen_androidpoc.MainActivity.test(MainActivity.java:60)
com.example.nworthen_androidpoc.MainActivity.onCreate(MainActivity.java:32)
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
android.app.ActivityThread.access$1500(ActivityThread.java:117)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:130)
android.app.ActivityThread.main(ActivityThread.java:3683)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:507)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
dalvik.system.NativeStart.main(Native Method)
My exceptions were not consistent (NullPointer, IOException, NetworkonMainThread). I added the posted code to an AsyncTask. Unfortunately, I'm not getting output on my Logcat anymore, but when debugging it kicks me to:
Class File Editor
Source not found
The JAR file C:/users..... has no source attachment. You can attach the source...
// Compiled from ThreadPoolExecutor.java (version 1.5 : 49.0, super bit)
public class java.util.concurrent.ThreadPoolExecutor extends java.util.concurrent.AbstractExecutorService {
// Method descriptor #17 (IIJLjava/util/concurrent/TimeUnit;Ljava/util/concurrent/BlockingQueue;)V
// Signature: (IIJLjava/util/concurrent/TimeUnit;Ljava/util/concurrent/BlockingQueue<Ljava/lang/Runnable;>;)V
// Stack: 3, Locals: 7
public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue workQueue);
0 aload_0 [this]
1 invokespecial java.util.concurrent.AbstractExecutorService() [1]
4 new java.lang.RuntimeException [2]
7 dup
...
Did you make sure that your app has permission to access the Internet?
See: https://stackoverflow.com/a/442590/81821

Null pointer Exception while inserting json array into sqlite database

12-07 11:25:34.290: E/AndroidRuntime(9177): FATAL EXCEPTION: AsyncTask #2
12-07 11:25:34.290: E/AndroidRuntime(9177): java.lang.RuntimeException: An error occured while executing doInBackground()
12-07 11:25:34.290: E/AndroidRuntime(9177): at android.os.AsyncTask$3.done(AsyncTask.java:200)
12-07 11:25:34.290: E/AndroidRuntime(9177): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
12-07 11:25:34.290: E/AndroidRuntime(9177): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
12-07 11:25:34.290: E/AndroidRuntime(9177): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
12-07 11:25:34.290: E/AndroidRuntime(9177): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
12-07 11:25:34.290: E/AndroidRuntime(9177): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
12-07 11:25:34.290: E/AndroidRuntime(9177): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
12-07 11:25:34.290: E/AndroidRuntime(9177): at java.lang.Thread.run(Thread.java:1096)
12-07 11:25:34.290: E/AndroidRuntime(9177): Caused by: java.lang.NullPointerException
12-07 11:25:34.290: E/AndroidRuntime(9177): at com.UserLogin.Onaroundyou$getOnaroundyou.doInBackground(Onaroundyou.java:198)
12-07 11:25:34.290: E/AndroidRuntime(9177): at com.UserLogin.Onaroundyou$getOnaroundyou.doInBackground(Onaroundyou.java:1)
12-07 11:25:34.290: E/AndroidRuntime(9177): at android.os.AsyncTask$2.call(AsyncTask.java:185)
12-07 11:25:34.290: E/AndroidRuntime(9177): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
12-07 11:25:34.290: E/AndroidRuntime(9177): ... 4 more
When I'm trying to insert json array into my sqlite database i'm getting this Nullpoint exception error.
on Lline 198
we are getting the value from jsonarray adding it to content values. Till this line i'm getting values of json response i've printed key and value with in log. checked whether i'm getting any null values. But values are coming fine and i can able to see those in log. When my deguger entering into below line i'm gettng error. Please help once.
Evalues.put(InsertData.MyName,JSonArray1.getJSONObject(i).getString("MyName"));
Thanks in advance.
private TextView tv;
String str, Username, Eresult,Password;
ProgressDialog dialog1;
DatabaseHelper InsertEData;
String attributeId ;
Context mContext = this;
SQLiteDatabase Edb ;
JSONObject MyUserJsonObject;
protected Void doInBackground(String... params) {
// TODO Auto-generated method stub
HttpClient httpclient = new DefaultHttpClient();
// Dh.getWritableDatabase();
String text1 = getString(R.string.site_name);
String Url=text1+"Details";
HttpPost httppost = new HttpPost(Url);
try {
HttpResponse responseGet = httpclient.execute(httppost);
HttpEntity entity = responseGet.getEntity();
if (entity != null) {
InputStream inputStreamResponse = entity.getContent();
Eresult = convertStreamToString(inputStreamResponse);
System.out.println(Eresult);
Edb= InsertEData.getWritableDatabase();
ContentValues Evalues = new ContentValues();
Evalues.clear();
MyUserJsonObject = new JSONObject(Eresult);
JSONObject menuObject = MyUserJsonObject.getJSONObject("UserDetails");
attributeId = menuObject.getString("login");
System.out.println("attribute "+attributeId);
if (attributeId.equals("success")) {
JSONObject EObject = menuObject.getJSONObject("Ulist");
JSONArray EArray = EObject.getJSONArray("List");
System.out.println(EArray);
System.out.println(EArray.length());
for (int i = 0; i < EArray.length(); i++) {
//System.out.println(EArray.getJSONObject(0).getString("Name").toString());
Evalues.put(InsertEData.EName, EArray.getJSONObject(i).getString("MyName"));
Evalues.put(InsertEData.ELocation, EArray.getJSONObject(i).getString("Location"));
Evalues.put(InsertEData.ETotal, EArray.getJSONObject(i).getString("Total"));
Evalues.put(InsertEData.Eimage, EArray.getJSONObject(i).getString("Image"));
Edb.insert(InsertEData.ESLIST, null, Evalues );
}
Evalues.clear();
inputStreamResponse.close();
}else {
System.out.println("Unable to load page - " + responseGet.getStatusLine());
}
}
else
System.out.println("Entity Null");
} catch (JSONException e) {
// TODO Auto-generated catch block
System.out.println("Network Error");
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
return null;}
It seems like your array returns null value.
Please keep log and check and console.
"Can anyone know why this happening."
The short answer is: because some object is null where it shouldn't be. Potential culprits could be InsertData, JSonArray1, or the result of JSonArray1.getJSONObject(i).
Without more details it's hard to pinpoint the exact cause. I suggest you breakpoint your code in order to find the issue.

After HTTP GET request, the resulting string is cut-off - content has been consumed

I'm making a http get request like this:
try {
HttpClient client = new DefaultHttpClient();
String getURL = "http://busspur02.aseag.de/bs.exe?SID=5FC39&ScreenX=1440&ScreenY=900&CMD=CR&Karten=true&DatumT="+day+"&DatumM="+month+"&DatumJ="+year+"&ZeitH="+hour+"&ZeitM="+min+"&Intervall=60&Suchen=(S)uchen&GT0=Aachen&T0=H&HT0="+start_from+"&GT1=Aachen&T0=H&HT1="+destination+"";
HttpGet get = new HttpGet(getURL);
HttpResponse responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity();
if (resEntityGet != null) {
//do something with the response
Log.i("GET RESPONSE",EntityUtils.toString(resEntityGet));
}
...
} catch (...) {
...
}
It all works well... the only problem: the output from Log.i is cut-off... It's not the complete html page. If I make the same request in a browser, I get 3x the output in opposition to making the request in the emulator and using the above code.... what's wrong?
ERROR:
04-30 14:01:01.287: WARN/System.err(1088): java.lang.IllegalStateException: Content has been consumed
04-30 14:01:01.297: WARN/System.err(1088): at org.apache.http.entity.BasicHttpEntity.getContent(BasicHttpEntity.java:84)
04-30 14:01:01.297: WARN/System.err(1088): at org.apache.http.conn.BasicManagedEntity.getContent(BasicManagedEntity.java:100)
04-30 14:01:01.307: WARN/System.err(1088): at org.apache.http.util.EntityUtils.toString(EntityUtils.java:112)
04-30 14:01:01.307: WARN/System.err(1088): at org.apache.http.util.EntityUtils.toString(EntityUtils.java:146)
04-30 14:01:01.307: WARN/System.err(1088): at mjb.project.AVV.ParseHTML.start(ParseHTML.java:177)
04-30 14:01:01.307: WARN/System.err(1088): at mjb.project.AVV.ParseHTML.onCreate(ParseHTML.java:139)
04-30 14:01:01.307: WARN/System.err(1088): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-30 14:01:01.327: WARN/System.err(1088): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-30 14:01:01.327: WARN/System.err(1088): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-30 14:01:01.327: WARN/System.err(1088): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-30 14:01:01.347: WARN/System.err(1088): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-30 14:01:01.347: WARN/System.err(1088): at android.os.Handler.dispatchMessage(Handler.java:99)
04-30 14:01:01.347: WARN/System.err(1088): at android.os.Looper.loop(Looper.java:123)
04-30 14:01:01.347: WARN/System.err(1088): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-30 14:01:01.347: WARN/System.err(1088): at java.lang.reflect.Method.invokeNative(Native Method)
04-30 14:01:01.357: WARN/System.err(1088): at java.lang.reflect.Method.invoke(Method.java:521)
04-30 14:01:01.357: WARN/System.err(1088): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-30 14:01:01.357: WARN/System.err(1088): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-30 14:01:01.357: WARN/System.err(1088): at dalvik.system.NativeStart.main(Native Method)
OK I solved it.
As I understand, the content of the entity gets consumed if it's not "used". So I created a new String object with the content of the Entity, so to say a copy instead of a reference to the entity's content.
try {
HttpClient client = new DefaultHttpClient();
String getURL = "http://busspur02.aseag.de/bs.exe?SID=5FC39&ScreenX=1440&ScreenY=900&CMD=CR&DatumT="+day+"&DatumM="+month+"&DatumJ="+year+"&ZeitH="+hour+"&ZeitM="+min+"&Intervall=120&Suchen=(S)uchen&GT0=Aachen&T0=H&HT0="+start_from+"&GT1=Aachen&T0=H&HT1="+destination+"";
HttpGet get = new HttpGet(getURL);
HttpResponse responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity();
String sourceString = "";
if (resEntityGet != null) {
try {
dismissDialog();
sourceString= new String(EntityUtils.toString(resEntityGet));
Log.i("GET RESPONSE", sourceString);
} catch (ParseException exc) {
// TODO Auto-generated catch block
exc.printStackTrace();
} catch (IllegalStateException exc) {
// TODO Auto-generated catch block
exc.printStackTrace();
}
...
}
...
} catch(...) {
...
}
DixieFlatline is correct.
With this I get partial output:
Log.v(TAG, "RESPONSE: " + response);
With this I get full output:
for(String line : response.split("\n"))
Log.v(TAG, "LINE: " + line);
I think that Log limits the number of chars to 4070. I tried to display a long string in ddms locgat and i got only 4070 chars.
Great!
By the way, if you are using Eclipse with Debug perspective, at the "Variables" view:
(Window -> Show View -> Variables)
you can right-click on the window, select "Max Length" and insert "0".
This way you can see all the chars (the complete html) in the Variables view.

Categories