Flurry API in Mono for Android

3 work  |   November 14, 2012  |     1993

Hi Everyone,

We have been using Mono for Android at Taste Filter since may. I love coding in C#, it is much faster than coding in Java with all the shortcuts (events, delegates, actions, etc). Mono for Android is generally very good too.

One thing that is lacking, is the amount of Bindings available for it. We need fairly specific analytics at Taste Filter, since we are introducing new ways to interact with content, new touch enabled controls. We want to know what is going on; how people are interacting with it. Have using Google Analytics isn’t stellar; we want a better tool. More reporting, more information passed to the system gathering the stats.

I tried using the automated process for creating a binding from a JAR, but it didn’t yield good results; lots and lots of errors which I did not understand; didn’t seem to be documented.

I found a foundation

I then found this page. The guy had a solid foundation, but I had many questions. How do you determine those signatures? I mean, what is this?

_flurryOnEndSession = JNIEnv.GetStaticMethodID(_flurryClass, "onEndSession", "(Landroid/content/Context;)V");

Determining JNI function signatures

It turns out it was covered in the Xamarin Documentation, but I had overseen it. Sometimes I look for something too specific. You simply use javap.

javap -s -classpath android.jar fully.qualified.Java.Name

And it will give you the actual signature.

public final class java.lang.Thread$State extends java.lang.Enum{
public static final java.lang.Thread$State NEW;
Signature: Ljava/lang/Thread$State;
public static final java.lang.Thread$State RUNNABLE;
Signature: Ljava/lang/Thread$State;
public static final java.lang.Thread$State BLOCKED;
Signature: Ljava/lang/Thread$State;
public static final java.lang.Thread$State WAITING;
Signature: Ljava/lang/Thread$State;
public static final java.lang.Thread$State TIMED_WAITING;
Signature: Ljava/lang/Thread$State;
public static final java.lang.Thread$State TERMINATED;
Signature: Ljava/lang/Thread$State;
public static java.lang.Thread$State[] values();
Signature: ()[Ljava/lang/Thread$State;
public static java.lang.Thread$State valueOf(java.lang.String);
Signature: (Ljava/lang/String;)Ljava/lang/Thread$State;
static {};
Signature: ()V

Functions to bind

Since the session (activity) functions were covered already

  • onStartSession (Context context, String apiKey)
  • onEndSession (Context context)

First I wanted to have access to all logEvent functions, and ending timed events.

  • logEvent(String eventId)
  • logEvent(String eventId, boolean timed)
  • logEvent(String eventId, Map parameters)
  • logEvent(String eventId, Map parameters, boolean timed)
  • endTimedEvent (String eventId)

Then I wanted some demographic functions

  • setUserID(String)
  • setAge(int)
  • setGender(byte)

Finally, the error tracking function

  • static void onError (String errorId, String message, String errorClass)

End Result
I created a class that is called FlurryClient. This class registers the functions and give us an API. Thanks to Jonathan Pryor from Xamarin (I suggest reading that!) for the help.

Final source code can be found here.

Don’t forget to add the JAR file to your project, and select “AndroidJavaLibrary” as the action.

Good luck, ask for help if you need some


  • January 16, 2013 at 3:13 am


    Great! Thanks a lot! Exactly what I was looking for.

  • July 25, 2013 at 7:00 pm


    I have not been able to get this working. Everything integrates and builds fine, but in the end nothing is actually sent to my flurry dashboard… I have asked on stack-overflow and contacted flurry and neither were able to help me. Below is the stack-overflow to the unanswered question. I would greatly appreciate if you could give it a look, you might know the fix. Thank you.


  • October 31, 2013 at 8:44 am

    Martin Legris

    Just a note, it sometimes takes Flurry 24 hours to show results. But it does work.

Leave a Reply