[mono-android] How to add .java file class to my mono on android c# project ?

Jonathan Pryor jonp at xamarin.com
Tue Feb 14 21:50:29 UTC 2012


To add a .java file to your project, add it to your project (right-click your Project > Add > Add Files..., select files, OK), then select the .java file in the Project panel and set its build action to AndroidJavaSource.

Once you've done that, you can use JNIEnv to instantiate the Java class and invoke methods on it. See the SanityTests sample for an example:

	https://github.com/xamarin/monodroid-samples/blob/master/SanityTests/Adder.java
	https://github.com/xamarin/monodroid-samples/blob/master/SanityTests/Hello.cs#L514

 - Jon



More information about the Monodroid mailing list