运行到一行
tools = new Tools();
就会出现报错,然后崩溃。
05-18 08:36:37.698 2397-3910/com.google.android.googlequicksearchbox:search W/ErrorReporter: reportError [type: 211, code: 524300]: Error reading from input stream
05-18 08:36:37.724 2397-3910/com.google.android.googlequicksearchbox:search W/ErrorProcessor: onFatalError, processing error from engine(4)
com.google.android.apps.gsa.shared.speech.a.g: Error reading from input stream
at com.google.android.apps.gsa.staticplugins.recognizer.i.a.a(SourceFile:342)
at com.google.android.apps.gsa.staticplugins.recognizer.i.a$1.run(SourceFile:1367)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at com.google.android.apps.gsa.shared.util.concurrent.a.ak.run(SourceFile:66)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
at com.google.android.apps.gsa.shared.util.concurrent.a.ad$1.run(SourceFile:85)
Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space.
at com.google.android.apps.gsa.speech.audio.Tee.g(SourceFile:2531)
at com.google.android.apps.gsa.speech.audio.ap.read(SourceFile:555)
at java.io.InputStream.read(InputStream.java:101)
at com.google.android.apps.gsa.speech.audio.al.run(SourceFile:362)
at com.google.android.apps.gsa.speech.audio.ak$1.run(SourceFile:471)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at com.google.android.apps.gsa.shared.util.concurrent.a.ak.run(SourceFile:66)
at com.google.android.apps.gsa.shared.util.concurrent.a.ax.run(SourceFile:139)
at com.google.android.apps.gsa.shared.util.concurrent.a.ax.run(SourceFile:139)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
at com.google.android.apps.gsa.shared.util.concurrent.a.ad$1.run(SourceFile:85)
Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space.
线程读数据时候有问题,缓冲数据溢出。具体的没有代码看不出来。
Tools代码
package com.example.yi.util;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Message;
import android.widget.EditText;
import android.widget.Toast;
import com.example.yi.UrlUtil;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Handler;
import static com.example.yi.UrlUtil.BASE_URL;
/**
public class Tools {
public ArrayList InfoList = null;
public ArrayList getInfoContent(final Context context, final android.os.Handler handler, final int what) {
class myTread extends Thread {
@Override
public void run() {
try {
String result = null;
String url = BASE_URL + "/APP/LookServlet?loca=12&locb=13&month=4";
System.out.println(url);
result = UrlUtil.getUrlString(url);
System.out.println(result);
JSONObject json = new JSONObject(result);
JSONArray jsonarray = json.getJSONArray("json");
for (int i = 0; i < jsonarray.length(); i++){
MyInfo myInfo =new MyInfo();
JSONObject world=jsonarray.getJSONObject(i);
String text=world.getString("word");
JSONArray imageContext=world.getJSONArray("pic");
myInfo.setText(text);
Boolean haveImg=false;
if(imageContext!=null){
haveImg=true;
String[] pics=new String[imageContext.length()];
for (int n=0;n JSONObject img=imageContext.getJSONObject(n);
pics[n]= img.getString("picture");
}
myInfo.setImageContext(pics);
}
/*myInfo.setHaveImage(haveImg);
myInfo.setId(world.getString("uid"));
StringBuilder time =new StringBuilder(world.getString("ct"));
time.delete(time.length()-2,time.length());
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date=format.parse(time.toString());
SimpleDateFormat format1 = new SimpleDateFormat(
"yyyy年MM月dd日 HH:mm");
String time1=format1.format(time);*/ //日期格式化
myInfo.setTime(world.getString("ct"));
if (InfoList==null){
InfoList=new ArrayList();
}
InfoList.add(myInfo);
}
Message message=handler.obtainMessage();
message.obj=InfoList;
message.what=what;
handler.sendMessage(message);
} catch (Exception e) {
e.printStackTrace();
Message message=handler.obtainMessage();
message.obj=InfoList;
message.what=3;
handler.sendMessage(message);
}
}
}
Thread one= new myTread();
one.start();
/* try {
one.join();
} catch (InterruptedException e) {
System.out.println(one.isAlive());
e.printStackTrace();
}*/
return InfoList;
}
}
for (int n=0;n JSONObject img=imageContext.getJSONObject(n);
pics[n]= img.getString("picture");这是什么鬼?
其次你可以继续dug深入,找到具体某行代码