当前位置: 代码迷 >> Android >> Android的Bug征集机制建立
  详细解决方案

Android的Bug征集机制建立

热度:77   发布时间:2016-05-01 16:51:36.0
Android的Bug收集机制建立

/**

*给TextView添加点击事件故意抛出异常

*/
??textView.setOnClickListener(new OnClickListener() {

[email protected]
???public void onClick(View v) {
????// TODO Auto-generated method stub
????Main main = new Main();
????try {
?????main.add();
????} catch (Exception e) {
?????try {

/**

*将异常记录

*/
??????OutputStream out = mContext.openFileOutput("bug.txt",
??????????ExceptionTestActivity.this.MODE_APPEND);//如果没有该文件会自动创建
??????PrintStream ps = new PrintStream(out);
??????e.printStackTrace(ps);

try {
???FileInputStream fis = mContext.openFileInput("bug.txt");//没有该文件的时候会抛异常

???InputStreamReader isr = new InputStreamReader(fis);
???BufferedReader br = new BufferedReader(isr);
???StringBuilder sb = new StringBuilder();
???String line = null;
???while ((line = br.readLine()) != null) {
????sb.append(line);
???}
???fis.close();
???textView.setText(sb.toString());
??} catch (Exception e2) {
???e2.printStackTrace();
??}


?????} catch (FileNotFoundException e1) {
??????// TODO Auto-generated catch block
??????e1.printStackTrace();
?????}

????}

???}
??});

  相关解决方案