How do you access a custom Java class from Unity?

Hi,

I know the question above is possible, I’ve seen the Unity Plugins page- however, with a .Jar created from the below code, I get

Class lookup Ljava/lang/NullPointerException; attempted while exception Ljava/lang/RuntimeException; pending

in the Logcat and the app exits.

What am I doing wrong here?

My Unity-side Javascript code is:


	var jo:AndroidJavaObject= new AndroidJavaObject("co.uk.damiensturdy.UnityIntents.SBIntentPluginActivity");
	jo.Call("InitIntent");
	jo.Call("setAction","com.bn.sdk.shop.details");
	jo.Call("putExtra","product_details_ean","2940043892355");
	jo.Call("startActivity");

and my Java code is:


package co.uk.damiensturdy.UnityIntents;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;

public class SBIntentPluginActivity extends Activity {

	private Intent androidIntent;
	
	public void InitIntent() 
	{
		androidIntent = new Intent();
	}
	    
    public void InitIntentUriParse(String uri) {
    	androidIntent=new Intent(Intent.ACTION_VIEW,Uri.parse(uri));
    }
	
	public void setAction( String action) {
		androidIntent.setAction(action); 
	}
	
	public void putExtra(String key,String value) {
		androidIntent.putExtra(key,value);
	}
	
	public void startActivity() {
		startActivity(androidIntent);
		
	}
}

I’ve not done this with Javascript but SBIntentPluginActivity is a class so you should be using using AndroidJavaClass rather than AndroidJavaObject.