public class MainActivity extends Activity {
private UnityPlayer m_UnityPlayer; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); m_UnityPlayer = new UnityPlayer(this); int glesMode = m_UnityPlayer.getSettings().getInt("gles_mode", 1); boolean trueColor8888 = false; m_UnityPlayer.init(glesMode, trueColor8888); setContentView(R.layout.activity_main); // Add the Unity view FrameLayout layout = (FrameLayout) findViewById(R.id.frameLayout2); LayoutParams lp = new LayoutParams (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layout.addView(m_UnityPlayer.getView(), 0, lp); }}main.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/frameLayout2" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="@string/hello_world" tools:context=".MainActivity" /></FrameLayout>