Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android plugin is not initialized properly. #10

Open
injeniero opened this issue Apr 21, 2016 · 0 comments
Open

Android plugin is not initialized properly. #10

injeniero opened this issue Apr 21, 2016 · 0 comments

Comments

@injeniero
Copy link

Android plugin is not being initialize properly. We need to grab the Context and pass it to initialize. This allows Android to capture automatic breadcrumbs.

diff --git a/DemoApp/Assets/Plugins/Crittercism/Crittercism_Android_Scripts/CrittercismAndroid.cs b/DemoApp/Assets/Plugins/Crittercism/Crittercism_Android_Scripts/CrittercismAndroid.cs
index 0a11741..37b39cf 100644
--- a/DemoApp/Assets/Plugins/Crittercism/Crittercism_Android_Scripts/CrittercismAndroid.cs
+++ b/DemoApp/Assets/Plugins/Crittercism/Crittercism_Android_Scripts/CrittercismAndroid.cs
@@ -54,7 +54,9 @@ public static class CrittercismAndroid

     using (var cls_UnityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer")) {
       using (var objActivity = cls_UnityPlayer.GetStatic<AndroidJavaObject> ("currentActivity")) {
-        PluginCallStatic ("initialize", objActivity, appID, config.GetAndroidConfig ());
+        using (var objContext = objActivity.Call<AndroidJavaObject> ("getApplicationContext")) {
+          PluginCallStatic ("initialize", objContext, appID, config.GetAndroidConfig());
+        }
       }
     }

diff --git a/Plugins/Crittercism/Crittercism_Android_Scripts/CrittercismAndroid.cs b/Plugins/Crittercism/Crittercism_Android_Scripts/CrittercismAndroid.cs
index 0a11741..37b39cf 100644
--- a/Plugins/Crittercism/Crittercism_Android_Scripts/CrittercismAndroid.cs
+++ b/Plugins/Crittercism/Crittercism_Android_Scripts/CrittercismAndroid.cs
@@ -54,7 +54,9 @@ public static class CrittercismAndroid

     using (var cls_UnityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer")) {
       using (var objActivity = cls_UnityPlayer.GetStatic<AndroidJavaObject> ("currentActivity")) {
-        PluginCallStatic ("initialize", objActivity, appID, config.GetAndroidConfig ());
+        using (var objContext = objActivity.Call<AndroidJavaObject> ("getApplicationContext")) {
+          PluginCallStatic ("initialize", objContext, appID, config.GetAndroidConfig());
+        }
       }
     }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant