Can I trigger Android's built-in bug capture functionality from my app?
android, android-debug, debugging, logcat
Solution
Reading up on the link that you have posted - What does it mean with bug report captured in android tablet?
The [answer] marked as correct says `bugmailer.sh` in the `system/bin` does the reporting.
So, in theory if you could detect an app crash using any of these methods, then you could execute your own copy of `bugmailer.sh` in the sdcard and get a report.
Source for `bugmailer.sh`: https://android.googlesource.com/platform/system/extras/+/android-4.2.2_r1/bugmailer/bugmailer.sh
However, you will realize that this will obviously work only for rooted phones as you read the source.
The easier way would be to open the `Developer options` and have a system overlay window pointing at what they should click. This would be the only user friendly solution for non rooted phones.
You can open the `Developer options` using
startActivity(new Intent(
Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS));
For further reference.
Problem
Android has, from ICS onwards (I think) provided the ability for a user to capture the system state, and then send or share the captured data with whomever they wish. See What does it mean with bug report captured in android tablet? The captured data includes a screenshot, list of running processes, Logcat contents, active threads for each process, etc. This is fantastically useful, but triggering it seems to involve the user pressing funny key combinations (Power + VolumeUp + VolumeDown) or enabling Developer mode and choosing specific options from there (Take bug report, Power menu bug reports). Is there a way I can trigger this from my own code, so that I can offer my users a simple menu option to capture a bug report?