Skip to content

cgoodroe/de-tools-bugreport-android

 
 

Repository files navigation

#Bug Reporter

A simple library to collect the database, cache, files and basic device information from an application.

Getting started

In your build.gradle:

repositories {
    ...
    maven { url "https://jitpack.io" }
}

 dependencies {
    debugCompile 'com.github.doubleencore.de-tools-bugreport-android:bugreport-library:0.4.7'
    releaseCompile 'com.github.doubleencore.de-tools-bugreport-android:bugreport-library-no-op:0.4.7'
 }

In your Application class:

public class ExampleApplication extends Application {

  @Override public void onCreate() {
    super.onCreate();
    BugReport.setup(this);
  }
}

If you want to trigger a report from a screenshot, in your Activity or Fragment class:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onResume() {
        super.onResume();
        BugReport.enableObserver(this);
    }

    @Override
    protected void onPause() {
        BugReport.enableObserver(this);
        super.onPause();
    }
}

Permissions

The library which should be included with debug builds requires WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE. The no-op version does not have any permissions requirements.

If supporting M, the activity which enables the observer, or executes a collection will need to implement onRequestPermissionsResult():

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
        boolean granted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
        switch (requestCode) {
            case BugReport.ENABLE_OBSERVER:
                if (granted) BugReport.enableObserver(this);
                break;
            case BugReport.EXECUTE_COLLECTION:
                if (granted) BugReport.executeCollection(this);
                break;
        }
    }

Generating a report

To manually trigger a report:

    BugReport.executeCollection(this);

Or if you have enabled screenshot monitoring, simply trigger a screenshot on the device.

Both will result in a notification displaying which will allow you send a .zip file of the contents.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%