When quit UnityPlayer, the whole application will be terminated, how to avoid it?

Hello, everyone, I’m new here。

Recently I’m developing a android application integrated a unity3d demo as a subview in it, I want to use button in android to control UnityPlayer, when I called UnityPlayer.quit(), I found that the whole application was terminated, I have googled, and someone told me that I should start unity activity in another process, but after adding android: process attribute to AndroidManifast.xml, it didn’t work.

Could someone help me? Thanks very much!
I’m using unity3d 5.0.0, my code:

// actually this is java code, but I can't find java in code editor, sorry~
@Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch(v.getId()){
        case R.id.openButton:
            // create a unity player object
            m_UnityPlayer = new UnityPlayer(this);
            int glesMode = m_UnityPlayer.getSettings().getInt("gles_mode", 1);
            m_UnityPlayer.init(glesMode, false);
     
            // add it to the frame layout
            m_UnityLayout = new FrameLayout(this);
            LayoutParams lp = new LayoutParams(200, 400);
            addContentView(m_UnityLayout, lp);
           
            m_UnityLayout.addView(m_UnityPlayer.getView());
            m_UnityPlayer.requestFocus();
            break;
           
        case R.id.closeButton:
          
            m_UnityLayout.removeView(m_UnityPlayer);           
            m_UnityPlayer.quit();
            break;
        }
    }

and my AndroidManifast.xml:

<application android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

        <activity android:name=".MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <actionandroid:name="android.intent.action.MAIN"/>
                <categoryandroid:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
   
        <activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
            android:label="embededUnity" 
            android:screenOrientation="fullSensor"
            android:launchMode="singleTask"
            android: processs=":unityprocess"     android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale">
          <meta-dataandroid:name="unityplayer.UnityActivity"android:value="true"/>
          <meta-dataandroid:name="unityplayer.ForwardNativeEventsToDalvik"android:value="false"/>
        </activity>
    </application>
1 Like

Were you able to fix it?