我想在我的应用中启用一些错误报告,因为我正在寻找一种适用于高于api等级8的设备的方式
我当前的实现在Android 4.1.1设备上不起作用,当用户按下错误报告按钮时没有动作。在设备2.2,2.3和4.0.4上,它显示了不同的电子邮件选项。
我的代码中的操作方法如下所示
public void startSendErrorAction(View view) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType( "text/plain" );
intent.putExtra( Intent.EXTRA_EMAIL, new String[]{"my@email.de" });
intent.putExtra( Intent.EXTRA_SUBJECT, "PDiXAttach LogReport from " + DateTime.now());
intent.putExtra( Intent.EXTRA_TEXT, getLogContent() );
startActivity(intent);
}
getLogContent方法使用logcat -d选项检索应用程序日志条目。但它目前无法在设备上运行
Hersteller: samsung
Modell: GT-N7100
Marke: samsung
Version: 4.1.1 (REL)
这里是getLogContent-Method
public String getLogContent() {
StringBuffer sb = new StringBuffer();
String separator = System.getProperty( "line.separator" );
Process process;
try {
process = Runtime.getRuntime().exec( "logcat -d" );
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader( process.getInputStream() ) );
String line;
while( (line = bufferedReader.readLine()) != null ) {
sb.append( line );
sb.append( separator );
}
Log.d( TAG, "retrieve log content size is " + sb.length() );
}
catch( IOException e ) {
Log.e( TAG, "error while retrieving logfile of application" + e.getMessage() );
}
return sb.toString();
}
有人知道可能是什么原因。