• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by tumashov · May 20, 2013 at 05:34 AM · android

[Fixed] Unity3d integration Flurry Android

Hi all! :) I tried for integration Flurry in Unity3d, but now data not show in Flurry... I dont have any errors/warning (logcat too).

FlurryAgent class:

 using UnityEngine;
 using System.Collections;
 using System.Runtime.InteropServices;
 using System.Collections.Generic;
 
 public class FlurryAgent : MonoBehaviour {
     private AndroidJavaObject mCurrentActivity = null;
     private AndroidJavaClass mFlurryClass = null;
     
     public FlurryAgent() {
         if (Application.platform == RuntimePlatform.Android) {
             AndroidJavaClass unityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
             mCurrentActivity = unityPlayer.GetStatic<AndroidJavaObject> ("currentActivity");
             mFlurryClass = new AndroidJavaClass("com.flurry.android.FlurryAgent");
         }
     }
     
     public void StartSession(string API_KEY) {
         if (Application.platform == RuntimePlatform.Android) {
             mFlurryClass.CallStatic("setLogLevel", 2);
             mFlurryClass.CallStatic("setLogEnabled", true);
             mFlurryClass.CallStatic("setLogEvents", true);
             
             mFlurryClass.CallStatic("setCaptureUncaughtExceptions", true);
             
             mFlurryClass.CallStatic("onStartSession", mCurrentActivity, API_KEY);
         }
     }
     
     public void EndSession() {
         if (Application.platform == RuntimePlatform.Android) {
             mFlurryClass.CallStatic("onEndSession", mCurrentActivity);
         }
     }
     
     public int GetAgentVersion() {
         if (Application.platform == RuntimePlatform.Android) {
             return mFlurryClass.CallStatic<int>("getAgentVersion");
         }
         
         return 0;
     }
     
     public void LogEvent(string eventId, bool timed = false) {
         if (Application.platform == RuntimePlatform.Android) {
             if (timed == false)
                 mFlurryClass.CallStatic("logEvent", eventId);
             else
                 mFlurryClass.CallStatic("logEvent", eventId, true);
         }
     }
     
     public void LogEvent (string eventId, Dictionary<string, string> parameters, bool timed = false) {
         using(AndroidJavaObject obj_HashMap = new AndroidJavaObject("java.util.HashMap")) {
         
             System.IntPtr method_Put = AndroidJNIHelper.GetMethodID(obj_HashMap.GetRawClass(), "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
             
             object[] args = new object[2];
             
             foreach (KeyValuePair<string, string> kvp in parameters) {
                 using(AndroidJavaObject k = new AndroidJavaObject("java.lang.String", kvp.Key)) {
                     using(AndroidJavaObject v = new AndroidJavaObject("java.lang.String", kvp.Value)) {
                         args[0] = k;
                         args[1] = v;
                         AndroidJNI.CallObjectMethod(obj_HashMap.GetRawObject(),
                                                     method_Put, AndroidJNIHelper.CreateJNIArgArray(args));
                     }
                 }
             }
             if (timed == false)
                 mFlurryClass.CallStatic("logEvent", eventId, obj_HashMap);
             else
                 mFlurryClass.CallStatic("logEvent", eventId, obj_HashMap, true);
         }
     }
     
     public void EndTimedEvent(string eventId) {
         if (Application.platform == RuntimePlatform.Android) {
             mFlurryClass.CallStatic("endTimedEvent", eventId);
         }
     }
 }

Using:

     private static FlurryAgent FlurryAgent;
     void Awake() {
         FlurryAgent = gameObject.AddComponent<FlurryAgent>();
         FlurryAgent.StartSession(FLURRY_API);
         FlurryAgent.LogEvent(Application.loadedLevelName);
         FlurryAgent.EndSession();
     }

Android manifest:

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" android:theme="@android:style/Theme.NoTitleBar" package="Example.com" android:versionName="1.0" android:versionCode="1">
   <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
   <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false">
     <activity android:name="com.unity3d.player.UnityPlayerProxyActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="landscape">
       <intent-filter>
         <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.LAUNCHER" />
       </intent-filter>
     </activity>
     <activity android:name="com.unity3d.player.UnityPlayerActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="landscape">
     </activity>
     <activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="landscape">
       <meta-data android:name="android.app.lib_name" android:value="unity" />
       <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
     </activity>
     <activity android:name="com.flurry.android.FlurryAgent" android:configChanges="keyboardHidden|orientation" />
   </application>
   <uses-feature android:glEsVersion="0x00020000" />
   <uses-sdk android:minSdkVersion="6" android:targetSdkVersion="17" />
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 </manifest>

Other network connections via WWW class work fine.

Help me please! :)

FIXED: This is #$%@$ DELETED AdBlock, and hosts clear... :) I fix it adding 74.217.75.7 data.flurry.com to hosts. I dont know why deleted AdBlock work. %)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with Flurry 1 Answer

Unity Android Flurry error 1 Answer

HELP first person controller setup iphone/android 2 Answers

Player size statistics in Editor.log - last scene is huge even in it;s empty 0 Answers

Notification is received but not displayed using Parse Unity SDK + Android 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges