Coder Social home page Coder Social logo

bugsnag-android's Introduction

Bugsnag Notifier for Android

The Bugsnag Notifier for Android gives you instant notification of exceptions thrown from your Android applications. The notifier hooks into Thread.UncaughtExceptionHandler, which means any uncaught exceptions will trigger a notification to be sent to your Bugsnag project.

Bugsnag captures errors in real-time from your web, mobile and desktop applications, helping you to understand and resolve them as fast as possible. Create a free account to start capturing exceptions from your applications.

Installation & Setup

Download the latest bugsnag.jar file and place it in your Android app's libs/ folder.

Import the Bugsnag package in your Application subclass.

import com.bugsnag.android.*;

In your application's onCreate function, register to begin capturing exceptions:

Bugsnag.register(this, "your-api-key-goes-here");

Don't forget to register your Application subclass in your AndroidManifest.xml like this:

<application android:name=".ExampleApplication">
	[activity declarations and more...]
</application>

Recommended: Inherit from BugsnagActivity

To have additional useful data about exceptions sent to Bugsnag, you should also have each of your Activity classes inherit from BugsnagActivity. This will track which of your activities were open at the time of any exception, and present them in your Bugsnag error dashboard.

class MyActivity extends BugsnagActivity {
    ...
}

Send Non-Fatal Exceptions to Bugsnag

If you would like to send non-fatal exceptions to Bugsnag, you can pass any Throwable object to the notify method:

Bugsnag.notify(new RuntimeException("Non-fatal"));

You can also send additional meta-data with your exception:

Map<String,String> extraData = new HashMap<String,String>();
extraData.put("username", "bob-hoskins");
extraData.put("registered_user", "yes");

Bugsnag.notify(new RuntimeException("Non-fatal"), extraData);

Configuration

###setContext

Bugsnag uses the concept of "contexts" to help display and group your errors. Contexts represent what was happening in your application at the time an error occurs. In an android app, it is useful to set this to be your currently active Activity.

If you are using BugsnagActivity then this is set automatically for you. If you would like to set the bugsnag context manually, you can call setContext:

Bugsnag.setContext("MyActivity");

###setUserId

Bugsnag helps you understand how many of your users are affected by each error. In order to do this, we send along a userId with every exception. By default we will generate a unique ID and send this ID along with every exception from an individual device.

If you would like to override this userId, for example to set it to be a username of your currently logged in user, you can call setUserId:

Bugsnag.setUserId("leeroy-jenkins");

###setReleaseStage

If you would like to distinguish between errors that happen in different stages of the application release process (development, production, etc) you can set the releaseStage that is reported to Bugsnag.

Bugsnag.setReleaseStage("development");

By default this is set to be "production".

###setNotifyReleaseStages

By default, we will only notify Bugsnag of exceptions that happen when your releaseStage is set to be "production". If you would like to change which release stages notify Bugsnag of exceptions you can call setNotifyReleaseStages:

Bugsnag.setNotifyReleaseStages(new String[]{"production", "development"});

###setAutoNotify

By default, we will automatically notify Bugsnag of any fatal exceptions in your application. If you want to stop this from happening, you can call setAutoNotify:

Bugsnag.setAutoNotify(false);

###setExtraData

It if often very useful to send some extra application or user specific data along with every exception. To do this, you can call the setExtraData method:

Map<String,String> extraData = new HashMap<String,String>();
extraData.put("username", "bob-hoskins");
extraData.put("registered_user", "yes");

Bugsnag.setExtraData(extraData);

###setFilters

Sets the strings to filter out from the extraData maps before sending them to Bugsnag. Use this if you want to ensure you don't send sensitive data such as passwords, and credit card numbers to our servers. Any keys which contain these strings will be filtered.

Bugsnag.setFilters(new String[]{"password", "credit_card_number"});

By default, filters is set to new String[] {"password"};

Building from Source

To build a .jar file from source, clone the bugsnag-android repository and run:

ant package

This will generate a file named bugsnag.jar.

Reporting Bugs or Feature Requests

Please report any bugs or feature requests on the github issues page for this project here:

https://github.com/bugsnag/bugsnag-android/issues

Contributing

License

The Bugsnag Android notifier is free software released under the MIT License. See LICENSE.txt for details.

bugsnag-android's People

Contributors

jschwertfeger avatar loopj avatar mac-cain13 avatar snmaynard avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.