13

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?

Community
  • 1
  • 1
Graham Borland
  • 60,055
  • 21
  • 138
  • 179
  • 1
    Is [this](http://stackoverflow.com/a/9350486/1893766) not what you are looking for? – ozbek Jun 02 '14 at 12:18
  • 1
    @shoerat No, that is about directing users to leave feedback on Google Play. I am looking for a way to invoke the specific bug-capture reporting functionality which includes system log data. – Graham Borland Jun 02 '14 at 13:17
  • It would be nice to trigger it and get the results but I don't think there is a way to do that. It would be a bug if there is, android warn us about it after all _"Bug reports contain data from the system's various log files, including personal and private information. Only share bug reports with apps and people you trust."_ – Onur Jun 02 '14 at 15:29
  • @Onur I agree, and I would be happy for that warning to be displayed to my users! I don't want to read or store the log data in my app; I just want a way of triggering the overall process, so my users don't have to enable Developer mode or fiddle about with stupidly awkward keypress combinations. – Graham Borland Jun 02 '14 at 15:41
  • 2
    After looking through the AOSP source, I can say that the answer to the question is *no* – ozbek Jun 03 '14 at 06:28
  • 1
    Without the screenshot, please see http://stackoverflow.com/questions/10559267/how-to-use-intent-action-app-error-as-a-means-for-a-feedback-framework-in-andr – rds Jun 06 '14 at 19:37

4 Answers4

2

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
Karthik Balakrishnan
  • 4,353
  • 6
  • 37
  • 69
0

I have found a way but it requires root.

What responsible of bug report is dumpstate.c.

usage: dumpstate [-b soundfile] [-e soundfile] [-o file [-d] [-p] [-z]] [-s] [-q ]
-o: write to file (instead of stdout)
-d: append date to filename (requires -o)
-z: gzip output (requires -o) -p: capture screenshot to filename.png (requires -o)
-s: write output to control socket (for init)
-b: play sound file instead of vibrate, at beginning of job
-e: play sound file instead of vibrate, at end of job
-q: disable vibrate
-B: send broadcast when finished (requires -o and -p)

If dumpstate called with -B parameter, it broadcasts "android.intent.action.BUGREPORT_FINISHED" after that BugreportReceiver handles warning the user and sharing the result.

I haven't try it but, everyone who has root privileges can call dumpstate like

dumpstate -o dump -p -B

to trigger it.

Onur
  • 5,617
  • 3
  • 26
  • 35
0

As far as I know, users get the option to report a crash to the Google play.

There are sites that offer this functionality though, https://www.bugsense.com/ for example is easily integrated and also offers graddle/maven support. By using sites like these, you are sharing your data with them most likely though. That will be a trade of you have to make.

Gooey
  • 4,740
  • 10
  • 42
  • 76
0

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?

There is a library called ACRA (Application Crash Reports for Android ) which allows you to send crash reports to any destinations from your own code. Developer configurable user interaction such as silent reports, Toast notification, status bar notification + dialog or direct dialog are available.

You can add your own log file extracts as well as logcat, eventlog or radiolog to reports. It's a very useful tool for crash data analysis and reports management for developers.

Also See BasicSetup and AdvancedUsage.

Aung Myo Linn
  • 2,820
  • 3
  • 27
  • 38