0

I want to enable some error report in my app, for that I am searching for a way which works in devices higher than api level 8

My current implementation does not work on a Android 4.1.1 device, there is no action when the user presses the error report button. On a device 2.2, 2.3 and 4.0.4 it shows the different email options.

The action method in my code looks like this

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);        

}

The getLogContent Method retrieves the application log entries with the logcat -d option. But it currently does not work on the device

Hersteller: samsung
Modell: GT-N7100
Marke: samsung
Version: 4.1.1 (REL)

Here the 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();

}

Does someone know what might be the reason.

4

2 回答 2

3

ACRA does an excellent job of what you want, and works on all android versions that I've bothered using it on. It provides way more details than the Google Play reports, and can be very helpful in tracking down bugs remotely.

于 2013-01-17T14:16:35.443 回答
0

You can also use Alogcat for runTime crashes.

于 2013-01-17T14:31:16.257 回答