Accessing variables from android java objects

Hi, I am writing a C# script for a plugin I am writing in which needs to get a string from an android java object. I can call functions and stuff using what I have right now but anytime I go to get a variable stored in the object it comes back blank. I have been using the AndroidJavaObject.GetStatic to try to call variables. I am not sure if I am using this right or not but here is my code…

C# Unity Side

using UnityEngine;
using System.Collections; public class FacebookInt : MonoBehaviour {

private AndroidJavaClass FBses; private AndroidJavaObject jo; public string FbEmail; public string FbName; public string FbID; bool alreadychecked=false; public bool logresp= false;

// Use this for initialization void Start () { // create our new actvity if (Application.platform==RuntimePlatform.Android) {FBses=new AndroidJavaClass(“com.codestormstudios.seeitextensions.Extensions”); jo= FBses.GetStatic(“currentActivity”); } }

void update () {

// use this only if were on login screen if (Application.loadedLevelName==“StartScreen”) {FBLoginListener ();}


void OnGUI () {

GUI.Label(new Rect(0,0,300,100),FbEmail); }

public void FBLogin () {

if (Application.platform==RuntimePlatform.Android) { FBses.CallStatic (“facebooklaunch”,0); }


// checks to see if we have completed sign in process. if so commence login sequence public void FBLoginListener () { if (!(alreadychecked)) { Debug.Log(“Got here FBLoginListener: failed”); logresp=jo.GetStatic(“FacbookLoginResult”); if (logresp) { Debug.Log(“Got here FBLoginListener: sucess”); FbID=jo.GetStatic(“useid”); FbEmail=jo.GetStatic(“email”); FbName=jo.GetStatic(“username”);

alreadychecked=true; }

else { FbID=“”; FbEmail=“”; FbName=“”; } } }

Here is my android side of things…

package com.BlockedName.BlockedName;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.unity3d.player.UnityPlayer;
import com.unity3d.player.UnityPlayerActivity;

public class Extensions extends UnityPlayerActivity{

// class variables ///////////////////////////////////
// Activity result function static int resultcheck; static int faceval; // Facebook vars public static String useid=“”; public static String email=“boo”; public static String username=“”; public static Boolean FacbookLoginResult=false; // toast function public static String ToastVal =“test”;

///////////////////////////////////////////////////// @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); unitytoast ();


public static void unitytoast ()
{ Toast workingtoast=Toast.makeText(UnityPlayer.currentActivity.getApplicationContext(), ToastVal, Toast.LENGTH_LONG);;


// Launcher functions

public static void facebooklaunch ( final int functionswitch) // send which Facebook function we want to use

{ resultcheck=1; faceval=functionswitch; Intent facebookint; facebookint = new Intent(UnityPlayer.currentActivity.getApplicationContext(),FacebookInt.class); // input the function value facebookint.putExtra( “functswitch” , functionswitch); final int result=1;

UnityPlayer.currentActivity.startActivityForResult(facebookint,result); }

@Override public void onActivityResult (int requestCode,int resultCode,Intent data) { super.onActivityResult(requestCode, resultCode, data);

switch (resultcheck) { case 1: // facebook function switch (faceval) { case 0:// login FacbookLoginResult=data.getBooleanExtra(“FacbookResult”, FacbookLoginResult); if (FacbookLoginResult==true) { useid=data.getStringExtra(“useid”); email=data.getStringExtra(“email”); username=data.getStringExtra(“username”); Log.d(“gotvals”,useid); Log.d(“gotvals”,email); Log.d(“gotvals”,username); }

else { useid=“”; email=“”; username=“”; }

break; }

break; }

} // class continues… }

I figured it out. It ended up that I just used unitysendmessage() from the native android side of things. I still world like to understand what the GetStatic functions do to vars.