What is the best practice to receive application logs of my app in an error case?
<p>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</p>

<p>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.</p>

<p>The action method in my code looks like this</p>

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

}
</code></pre>

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

<pre><code>Hersteller: samsung
Modell: GT-N7100
Marke: samsung
Version: 4.1.1 (REL)
</code></pre>

<p>Here the getLogContent-Method</p>

<pre><code>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();

}
</code></pre>

<p>Does someone know what might be the reason.</p>
