Android Project Error when using getApplication() for UnityPlayer ?

Hi ,in my android project ,i use "getApplication() " to init UnityPlayer ,like this:

     // Setup activity layout
	@Override protected void onCreate (Bundle savedInstanceState)
	{

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);

		getWindow().takeSurface(null);
		setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
		getWindow().setFormat(PixelFormat.RGB_565);

		mUnityPlayer = new UnityPlayer(getApplication());
		if (mUnityPlayer.getSettings ().getBoolean ("hide_status_bar", true))
			getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
			                       WindowManager.LayoutParams.FLAG_FULLSCREEN);

		setContentView(mUnityPlayer);
		mUnityPlayer.requestFocus();
	}

** But it crash .and the log is quite simple :**

dalvikvm(14086): Trying to load lib /data/app-lib/com.lioncat.test-2/libmain.so 0x437c7910

dalvikvm(14086): Added shared lib /data/app-lib/com.lioncat.test-2/libmain.so 0x437c7910

libc(14086): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 14086 (om.lioncat.test)

For some reason ,i have to use “getapplication” for unityplayer’s context instead of “Activity” . Any help or suggestion?

Usually you subclass Unity’s activity and create your own activity.

You don’t need to create the UnityPlayer, it is already created for you and your custom activity is assigned to its static currentActivity field.

See this link: Unity - Manual: Create and use plug-ins in Android

Specifically, under “Extending the UnityPlayerActivity Java Code”