I've just started working with Plugins, and I just can't get past this one issue. I can call functions that return strings just fine, I've been able to create a plugin to download files to the SD card (needed to use SSL), but I just can't seem to create a plugin that provides a native view or intent in any way. This is my first foray into writing anything native for the droid, so hopefully I'm just missing something obvious.
I started with the Unity Plugin example using a prebuilt JNI Library that can be found here. I'm using the build file (and thus Apache ANT) to compile my java.
So, now I've got a C# file with the following code pertaining to this:
This calls the function - as I can remove all the java code and just have it return a string, and it works properly.
My java code, though, seems to just freeze up the application. The file it calls is as follows:
This then calls into another file which contains this code:
At some point, this Java all compiled. But I've gone through so many alterations trying to get things to work, I've ended up with things no longer compiling due to two errors on the line "webActivity showWeb = new webActivity();" (can't find either symbol webActivity in that line). Even when it did compile, though, when I hit the button I had linked to call the Java code, it just froze.
In the end, I'm not sure what I'm missing here. I'm not completely shocked it's not working, but I just can't figure out for what reason (or reasons) it isn't working due to my unfamiliarity with the native android code. Any help would be very, very much appreciated, as I've attempted about 5-6 completely different routes to this point, and this is the closest I've come.
Bear in mind that my knowledge of Unity and its JNI calls is about 1 hour old now. Not knowing anything more than what you've typed here, there are a few things I can think of.
Where did you define R.id.webview1? In a normal Android application, using Eclipse as the IDE, R is an automatically generated Resource bundle that is parsed out based on the contents of layout.xml files. I don't see any such layout files in the linked sample project. I'm guessing that the build file created an Android project for you?
New activities in Android are launched via Intents, not with the 'new' keyword. You'll need to look at the documentation on how Intent objects are used to instantiate Activities. This leads into : What do you have in your AndroidManifest.xml file? Do you have one? You'll need to create one and specifically let the main application know that it's allowed to launch Intents. You also would need to let your webActivity have permissions to access the Internet.
I have no familiarity yet with using Apache ANT to build the project, so I'm afraid I don't know exactly what you're dealing with in terms of your project setup. If I have some time this evening I will check into the process and update my answer.