Android Fabric - send Caught Exceptions at custom interval
Asked Answered
A

2

4

According to Fabric documentation Fabric doc to reduce user traffic, caught exceptions are sent only when the app launches -

Crashlytics processes exceptions on a dedicated background thread, so the performance impact to your app is minimal. To reduce your users’ network traffic, Crashlytics batches logged exceptions together and sends them the next time the app launches.

try {
  myMethodThatThrows();
} catch (Exception e) {
  Crashlytics.logException(e);
  // handle your exception here!
}

But for this particular app, the app will be always on, and is not intended to be relaunched. So the question is -

How to force the logs to be sent after some time, or on some event?

Abbess answered 13/7, 2016 at 9:5 Comment(1)
6 years on, any solution?Auctioneer
B
0

Mike from Fabric here.

Currently our SDK doesn't offer a way to manually flush or push over the logs from a running Android app. Logged exceptions are sent on relaunch of the app.

Bowing answered 14/7, 2016 at 15:32 Comment(2)
Do you know about limitation to send logs in series? I have sent two Crashlytics.logException(e) with interval 3 seconds, but only last appear in Fabric console.Chromium
Logs sent that quickly together shouldn't have any issue with showing up. I'd recommend creating a new SO post or ask on TwitterCommunity.Bowing
D
1

I've created some kind of simple solution. Now reports are sent after restarting app. What if user won't restart app because gets an error? It's possible.

So if we want to send logs after closing app, we need to create simple "sticky" service.

public class ReportService extends Service {
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        System.err.println("ReportService refresh");
        return START_STICKY;
    }
}

And lets put startService(new Intent(context, ReportService.class)); line in onCreate method of main activity.

Now when app will close, service will launch code again - Crashlytics will send logged exceptions.

Dorinedorion answered 26/3, 2018 at 10:13 Comment(0)
B
0

Mike from Fabric here.

Currently our SDK doesn't offer a way to manually flush or push over the logs from a running Android app. Logged exceptions are sent on relaunch of the app.

Bowing answered 14/7, 2016 at 15:32 Comment(2)
Do you know about limitation to send logs in series? I have sent two Crashlytics.logException(e) with interval 3 seconds, but only last appear in Fabric console.Chromium
Logs sent that quickly together shouldn't have any issue with showing up. I'd recommend creating a new SO post or ask on TwitterCommunity.Bowing

© 2022 - 2024 — McMap. All rights reserved.