Запустите приложение Unity из приложений, когда оно в фоновом режиме. Странное поведение - PullRequest
0 голосов
/ 08 апреля 2020

Приложение имеет 2 действия:

  • A - разрешение / другие настройки (основной или открытый файл с этим приложением)
  • B - Переопределенная активность Unity.

Они вызывают: A-> B

При загрузке Unity (последнее действие) я минимизирую его до фона. Затем снова откройте приложение с тем же действием A. Появляется проблема: единство перезапускается полностью. Но я хотите, чтобы это единство было максимальным от фона.

Задание A: Манифест

     <activity
                android:name="com.myvr.ui.A_Activity"
                android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density"
                android:launchMode="singleTask"
                android:screenOrientation="portrait"
                android:theme="@style/ATheme"
                android:windowActionBar="false"
                android:windowContentOverlay="@null"
                android:windowFullscreen="true"
                android:windowNoTitle="true"
                android:windowSoftInputMode="adjustNothing">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="com.google.intent.category.CARDBOARD" />
                </intent-filter>
                <intent-filter tools:ignore="AppLinkUrlError">
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="android.intent.category.DEFAULT" />

                    <data android:mimeType="image/*" />
                    <data android:mimeType="video/*" />
                </intent-filter>

            </activity>

Задание A: Код

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        *staff*
        startUnity()
}

private fun startUnity(){
        val unityIntent = Intent(this, B_UNITY_Activity::class.java)
        unityIntent.setDataAndType(intent.data, intent.type)
        unityIntent.flags = (Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
        *other staff*
        startActivity(unityIntent)
}

Задание B (UNITY) .
Манифест:

        <activity
            android:name="com.myvr.ui.B_UNITY_Activity"
            android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density"
            android:excludeFromRecents="true"
            android:launchMode="singleTask"
            android:screenOrientation="landscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="com.google.intent.category.CARDBOARD" />
            </intent-filter>

            <meta-data
                android:name="unityplayer.UnityActivity"
                android:value="true" />
        </activity>

Код активности Unity: стандартный

override fun onCreate(savedInstanceState: Bundle?) {
        Log.i("A_Activity","onCreate>Intent:\n"+intent+"\n" )
        super.onCreate(savedInstanceState)
        ApplicationConfiguration.activityCurrent = this
        *and staff*
}

override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        *staff*
}

и LogCat (попробуйте запустить приложение через первое действие - открыть приложение).
in.fulldive .shell> имя пакета приложения

04-08 17:48:19.778 1807-8739/? I/PackageManager:   Action: "android.intent.action.VIEW"
04-08 17:48:19.778 1807-8739/? I/PackageManager:   Category: "android.intent.category.DEFAULT"
04-08 17:48:19.778 1807-8739/? I/PackageManager:   Type: "image/png"
04-08 17:48:19.778 1807-8739/? I/PackageManager:   AutoVerify=false
04-08 17:48:19.781 1807-8738/? I/ActivityManager: START u0 {act=android.intent.action.VIEW dat=content://com.android.providers.media.documents/document/image:324 flg=0x3000001 cmp=in.fulldive.shell/com.fulldive.ui.A_Activity} from uid 10085 on display 0
//<<remember image id in intent data>>
04-08 17:48:19.832 9495-9495/in.fulldive.shell I/Unity: onDestroy //<<Wat???????????
04-08 17:48:19.841 9495-9495/in.fulldive.shell I/Process: Sending signal. PID: 9495 SIG: 9
04-08 17:48:19.878 1807-4486/? I/ActivityManager: Config changes=480 {1.0 ?mcc?mnc en_US ldltr sw360dp w360dp h568dp 480dpi nrml port finger -keyb/v/h -nav/h s.107?spn}
04-08 17:48:19.965 1807-3417/? I/InputReader: Reconfiguring input devices.  changes=0x00000004
04-08 17:48:19.965 1807-1860/? E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 88)
04-08 17:48:19.965 1807-3417/? I/InputReader: Device reconfigured: id=5, name='input_mt_wrapper', size 1080x1920, orientation 0, mode 4, display id 0
04-08 17:48:19.965 1807-3417/? I/InputReader: Device reconfigured: id=8, name='synaptics_dsx_i2c', size 1080x1920, orientation 0, mode 1, display id 0
04-08 17:48:19.968 1807-3416/? W/InputDispatcher: channel '4a54f49 in.fulldive.shell/com.fulldive.ui.A_Activity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
04-08 17:48:19.969 1807-3416/? E/InputDispatcher: channel '4a54f49 in.fulldive.shell/com.fulldive.ui.A_Activity (server)' ~ Channel is unrecoverably broken and will be disposed!
04-08 17:48:19.977 1807-1823/? D/GraphicsStats: Buffer count: 9
04-08 17:48:19.978 1807-4154/? I/WindowState: WIN DEATH: Window{4a54f49 u0 in.fulldive.shell/com.fulldive.ui.A_Activity}//<< obviously : closing LAST activity A >>
04-08 17:48:19.978 1807-4154/? W/InputDispatcher: Attempted to unregister already unregistered input channel '4a54f49 in.fulldive.shell/com.fulldive.ui.A_Activity(server)'
04-08 17:48:19.979 1807-1824/? D/ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ id=138, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED] ], android.os.BinderProxy@4b434a2)
04-08 17:48:19.980 1807-3430/? D/ConnectivityService: releasing NetworkRequest NetworkRequest [ id=138, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED] ]
04-08 17:48:19.985 1807-3430/? E/ConnectivityService: RemoteException caught trying to send a callback msg for NetworkRequest [ id=138, legacyType=-1, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED] ]
04-08 17:48:19.986 1807-4443/? I/WindowState: WIN DEATH: Window{fc1f514 u0 in.fulldive.shell/com.fulldive.vr.B_UNITY_Activity}//<< obviously : closing LAST activity B(Unity) >>
04-08 17:48:20.028 4052-4052/? W/SessionManager: SessionManager.beginSession():50 Try to begin an already begun session [INPUT_SESSION], end it first
04-08 17:48:20.035 1807-8739/? I/ActivityManager: Process in.fulldive.shell (pid 9495) has died
04-08 17:48:20.055 1807-8739/? I/ActivityManager: Start proc 10694:in.fulldive.shell/u0a183 for activity in.fulldive.shell/com.fulldive.ui.A_Activity
04-08 17:48:20.479 10694-10694/in.fulldive.shell I/A_Activity: onCreate>Intent:
    Intent { act=android.intent.action.VIEW dat=content://com.android.providers.media.documents/document/image:327 flg=0x13000001 cmp=in.fulldive.shell/com.fulldive.ui.A_Activity}
//<<WTF??? Last intent whith last image id?no plz,noooooo!>>

ТАК. Кто-нибудь сталкивался с подобной проблемой?

...