Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #16 from MatkovIvan/fix/force-start-session
Browse files Browse the repository at this point in the history
Force start session in registerMetricsManager
  • Loading branch information
Benjamin Scholtysik (Reimold) authored Jun 14, 2017
2 parents 6ad2965 + 7879018 commit 953329b
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import android.app.Activity;
import android.os.Build;

import java.lang.reflect.Method;

public class HockeyUnityPlugin {

//region CONFIGURE AND START MODULES
Expand Down Expand Up @@ -138,6 +140,18 @@ public static void registerMetricsManager(final Activity currentActivity, final
@Override
public void run() {
MetricsManager.register(currentActivity, currentActivity.getApplication(), appID);

// Unity's awake calls after android activity shown.
// We force start session to avoid missing it.
try {
Method getInstance = MetricsManager.class.getDeclaredMethod("getInstance");
getInstance.setAccessible(true);
MetricsManager instance = (MetricsManager) getInstance.invoke(null);
Method updateSession = MetricsManager.class.getDeclaredMethod("updateSession");
updateSession.setAccessible(true);
updateSession.invoke(instance);
} catch (Throwable ignored) {
}
}
});
}
Expand Down

0 comments on commit 953329b

Please sign in to comment.