So i’ve been stuck on this problem for literally days. I have integrated Unity with Eclipse IDE and i can build and deploy projects perfectly. However, im trying to start an a basic Intent on the java side and trigger it on the Unity/C# side.
Here’s my code for the Java side:
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import com.unity3d.player.UnityPlayerNativeActivity;
public class AppLauncher extends UnityPlayerNativeActivity
{
public Intent myIntent;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//Assuming that we want to launch the browser to browse a website
Uri uri = Uri.parse("http://www.google.com");
myIntent= new Intent(Intent.ACTION_VIEW, uri);
}
public void Trigger()
{
startActivity(myIntent);
}
}
Here’s the error im getting thrown by logcat when the C# trigger is hit:
And here’s my code for the C# side of if it:
if(s[0].Equals("Spr"))
{
print("Launched");
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
jo.Call("Trigger");
}
Here’s the error im getting thrown by logcat when the C# trigger is hit:
AndroidJavaException: java.lang.NoSuchMethodError: no method with name='Trigger' signature='()V' in class Lcom/unity3d/player/UnityPlayerNativeActivity;
I’ve tried screwing around by passong a custom signature along with the Trigger method name in the C# script, ive tried extending the standard UnityPlayerActivity, etc… I’ve tried hours worth of stuff and i Cannot seem to solve tis problem.
Any help is greatly accepted!
EDIT
This is the application launch section of the manifest:
<application android:icon="@drawable/app_icon" android:label="@string/app_name" >
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name" android:screenOrientation="landscape" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>