Search code examples
androidservicebackgroundcrash-reportshockeyapp

How to let Hockeyapp collect Crash Reports of a Service?


I added the HockeyApp SDK to my Android App. This works as expected, and I also get crash reports of the main activity and the associated classes.

However, I did not figure out how I will get crash reports of the [in my case started & bound] Service. The UpdateManager only accepts Activities and is defined as

UpdateManager.register(Activity, String)

Any idea?


Solution

  • It is sufficient when the Activity calls the appropriate methods of the UpdateManager. The Service must only register the CrashManager by adding this line in e.g. onCreate()

    public void onCreate() {
        ...
        CrashManager.register(this, HOCKEY_APP_ID);
    }
    

    HOCKEY_APP_ID is the same ID as used in the Activity.

    However, the crash of the Service will only be committed to HockeyApp when the Activity restarts.