Q:

UnityPlayerActivity global initialization

I'd appreciate if you could advise on my problem.
I'm working on AR app using Vuforia SDK for Unity3D and Android plugins.
I have several ImageTargets and 3D models on my scene.
My class that works with android plugin looks like this:
public class AssetBundleAugmenter : MonoBehaviour, ITrackableEventHandler
{    
    void Start()
    {
        StartCoroutine(DownloadAndCache());
        mTrackableBehaviour = GetComponent<TrackableBehaviour>();
        if (mTrackableBehaviour)
        {
            mTrackableBehaviour.RegisterTrackableEventHandler(this);
        }
        init();        
    }
    public void OnTrackableStateChanged(
    TrackableBehaviour.Status previousStatus,
    TrackableBehaviour.Status newStatus)
    {
        if (newStatus == TrackableBehaviour.Status.DETECTED ||
        newStatus == TrackableBehaviour.Status.TRACKED ||
        newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
        {
            if (!mAttached && mBundleInstance)
            {
                // if bundle has been loaded, let's attach it to this trackable
                //...        
            }
            OnTrackingFound();
        }
        else
        {
            OnTrakingLost();

        }

    }  

     private void OnTrackingFound()
     {
         if (mTrackableBehaviour is ImageTargetAbstractBehaviour)
         {
             GetJavaObject().Call("OnMarkerFound");
         }
     }   

    void onButtonClicked(int index)
    {
        //Changing current 3D model material
    }

#if UNITY_ANDROID
        private AndroidJavaObject javaObj = null;
        //LISTENING TO BUTTON CLICK EVENTS FROM ANDROID
        private sealed class EventListner : AndroidJavaProxy
        {
            private AssetBundleAugmenter mReceiver;

            public EventListner(AssetBundleAugmenter receiver)
             : base("com.mypackage.myapp.ImageTargetTracker$Listner")
            {
                mReceiver = receiver;
            }

            public void onButtonClicked(int index) //change color of model
            {
                mReceiver.onButtonClicked(index);
            }
        }

        private AndroidJavaObject GetJavaObject()
        {
            if (javaObj == null)
            {
                javaObj = new AndroidJavaObject("com.mypackage.myapp.ImageTargetTracker");
            }
            return javaObj;
        }
        AndroidJavaObject activity;
        private void init()
        {
            // Retrieve current Android Activity from the Unity Player
            AndroidJavaClass jclass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            activity = jclass.GetStatic<AndroidJavaObject>("currentActivity");

            // Pass reference to the current Activity into the native plugin,
            GetJavaObject().Call("setActivity", activity, new EventListner(this));

        }   

    #else
        void init() {}
    #endif
}

So I attached this script to all of my ImageTargets on the scene, which I know must be wrong, because UnityPlayer gets initialized several times in my init() function. 
I tried to attach the script to ARCamera on my scene, and write initialization only there, but I'm not sure how to access currentActivity in scripts that work with ImageTargets. Also, I use listener - the interface in my plugin that listens to button clicks to fire some functionality in unity.
My plugin code:
public class ImageTargetTracker {
    public static interface Listner {
        public void onButtonClicked(int index);
    }
    private Listner mListner;
    protected Activity mCurrentActivity;
    public void setActivity(Activity activity, Listner listner)
    {
        mCurrentActivity = activity;
        mListner = listner;

        mCurrentActivity.runOnUiThread(new Runnable() {
            public void run() {
                LayoutInflater inflater = mCurrentActivity.getLayoutInflater();
                Resources resources =  mCurrentActivity.getResources();
                String pkgName = mCurrentActivity.getPackageName();

                int id = resources.getIdentifier("camera_layout", "layout", pkgName);
                View view = inflater.inflate(id, null);

                mCurrentActivity.addContentView(view, param);
                //INITIALIZING UI ELEMENTS HERE (DISPLAYED ON TOP OF CAMERA)
    }

    public void OnMarkerFound(){

        mCurrentActivity.runOnUiThread(new Runnable() {
            public void run() {
                //Showing some UI elements
            }
        });
    }
}

So, how can I globally initialize the Activity and my plugin class in Unity one time, and use them in all of my scripts?

A:

As discussed in the comments, I recommend using the singleton pattern.

