From: Gustavo Martin Morcuende Date: Sun, 21 Dec 2014 15:38:22 +0000 (+0100) Subject: Working around this bug: https://code.google.com/p/android/issues/detail?id=82157 X-Git-Tag: weatherinformation-1.0~1 X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=4654c38d530fca4e44174c3a8d13ae93050c31f7;p=AndroidWeatherInformation Working around this bug: https://code.google.com/p/android/issues/detail?id=82157 --- diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4c156e8..944f440 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -171,9 +171,13 @@ + diff --git a/app/src/main/java/name/gumartinm/weather/information/app/WeatherInformationApp.java b/app/src/main/java/name/gumartinm/weather/information/app/WeatherInformationApp.java index cca8dcf..b5e438d 100644 --- a/app/src/main/java/name/gumartinm/weather/information/app/WeatherInformationApp.java +++ b/app/src/main/java/name/gumartinm/weather/information/app/WeatherInformationApp.java @@ -38,8 +38,13 @@ public class WeatherInformationApp extends Application { if (BuildConfig.DEBUG_MODE) { Timber.plant(new Timber.DebugTree()); } else { - Timber.plant(new GoogleAnalyticsReportingTree( - new GoogleAnalyticsTrackers(this.getApplicationContext()))); + // Trying to avoid this bug: https://code.google.com/p/android/issues/detail?id=82157 + // When Google fixes the bug I will be able to rely on the AndroidManifest.xml configuration. + final GoogleAnalyticsTrackers analyticsTrackers = + new GoogleAnalyticsTrackers(this.getApplicationContext()); + analyticsTrackers.setGlobalTracker(); + + Timber.plant(new GoogleAnalyticsReportingTree(analyticsTrackers)); } } @@ -47,6 +52,7 @@ public class WeatherInformationApp extends Application { private enum TrackerName { EXCEPTIONS_TRACKER, // Tracker used when logging caught exceptions in this app. + GLOBAL_TRACKER, // Tracker used when logging uncaught exception in this app. }; private final HashMap mTrackers = new HashMap(); @@ -57,6 +63,14 @@ public class WeatherInformationApp extends Application { } /** + * Trying to avoid this bug: https://code.google.com/p/android/issues/detail?id=82157 + * When Google fixes the bug I will be able to rely on the AndroidManifest.xml configuration. + */ + private void setGlobalTracker() { + this.getTracker(TrackerName.GLOBAL_TRACKER); + } + + /** * Get tracker * @param trackerId * @return Tracker @@ -68,6 +82,8 @@ public class WeatherInformationApp extends Application { final Tracker t = (trackerId == TrackerName.EXCEPTIONS_TRACKER) ? analytics.newTracker(R.xml.exceptions_tracker) : + (trackerId == TrackerName.GLOBAL_TRACKER) ? + analytics.newTracker(R.xml.global_tracker) : analytics.newTracker(R.xml.exceptions_tracker); // Do not retrieve user's information. I strongly care about user's privacy.