Search Unity

Question Issue with "three loading dots" showing on Oculus when launching new activity from plugin

Discussion in 'VR' started by robinpalmqvist, Aug 26, 2021.

  1. robinpalmqvist

    robinpalmqvist

    Joined:
    Feb 15, 2017
    Posts:
    4
    Hi!
    I am very new to Android development and have set up a minimal project where I want to launch a new Activity from the Unity Activity running on quest/quest2 using an Android Java proxy class. The issue I am facing is that when i try to launch the new activity i get the "three loading dots" on the oculus headset and it stays there until I hit the home screen button returning me to the Oculus lobby. I can see that the plugin code is running my System.out.println in the Logcat but for some reason it will not display the simple layout related to the Activity.

    The plugin is exported as an AAR and put in the ..\Assets\Plugins\Android\libs path of the Unity project.


    Unity class calling plugin:

    Code (CSharp):
    1.  
    2. public class NativeCall : MonoBehaviour
    3. {
    4.     public void CalleNativePlugin()
    5.     {
    6. #if !UNITY_EDITOR
    7.         CalleNativePluginPrivate();
    8. #endif
    9.     }
    10.  
    11.     private void CalleNativePluginPrivate()
    12.     {
    13.         AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    14.         AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
    15.         AndroidJavaObject plugin = new AndroidJavaObject("com.example.minimumproduct.Proxy");
    16.         plugin.CallStatic("CreateActivity", currentActivity);          
    17.     }  
    18. }

    Proxy class:
    As commented in this part of the code it will start a new Activity displaying the Oculus browser when i create it as an implicit Intent but not when the Intent is created with my own class.

    Code (CSharp):
    1. package com.example.minimumproduct;
    2.  
    3. import android.app.Activity;
    4. import android.content.Intent;
    5. import android.net.Uri;
    6.  
    7. public class Proxy {
    8.  
    9.     public static void CreateActivity(Activity activity)
    10.     {
    11.         System.out.println("Creating activity");
    12.  
    13.         // Below is NOT working and gives the "three dots" ->
    14.         Intent myIntent = new Intent(activity, MainActivity.class);
    15.  
    16.         // Below is working and opens a browser ->
    17.         //Uri uri = Uri.parse("http://google.com");
    18.         // Intent myIntent = new Intent(Intent.ACTION_VIEW, uri);
    19.  
    20.         activity.runOnUiThread(new Runnable() {
    21.             @Override
    22.             public void run() {
    23.                 activity.startActivity(myIntent);
    24.             }
    25.         });
    26.     }
    27. }

    MainActivity Class:

    Code (CSharp):
    1. package com.example.minimumproduct;
    2.  
    3. import androidx.appcompat.app.AppCompatActivity;
    4. import android.os.Bundle;
    5.  
    6. public class MainActivity extends AppCompatActivity {
    7.  
    8.     @Override
    9.     protected void onCreate(Bundle savedInstanceState) {
    10.         super.onCreate(savedInstanceState);
    11.         setContentView(R.layout.activity_main);
    12.         System.out.println("On create was called");
    13.     }
    14. }

    Layout for MainActivity:

    Code (CSharp):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3.     xmlns:app="http://schemas.android.com/apk/res-auto"
    4.     xmlns:tools="http://schemas.android.com/tools"
    5.     android:layout_width="match_parent"
    6.     android:layout_height="match_parent"
    7.     android:background="#FF00FF"
    8.     tools:context=".MainActivity">
    9.  
    10.     <TextView
    11.         android:layout_width="wrap_content"
    12.         android:layout_height="wrap_content"
    13.         android:text="Hello World!"
    14.         app:layout_constraintBottom_toBottomOf="parent"
    15.         app:layout_constraintLeft_toLeftOf="parent"
    16.         app:layout_constraintRight_toRightOf="parent"
    17.         app:layout_constraintTop_toTopOf="parent" />
    18.  
    19. </androidx.constraintlayout.widget.ConstraintLayout>

    And finally gradle file for java plugin:

    Code (CSharp):
    1. plugins {
    2.     id 'com.android.library'
    3. }
    4.  
    5. android {
    6.     compileSdk 30
    7.  
    8.     defaultConfig {
    9.         minSdk 21
    10.         targetSdk 30
    11.         versionCode 1
    12.         versionName "1.0"
    13.  
    14.         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    15.     }
    16.  
    17.     buildTypes {
    18.         release {
    19.             minifyEnabled false
    20.             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    21.         }
    22.     }
    23.     compileOptions {
    24.         sourceCompatibility JavaVersion.VERSION_1_8
    25.         targetCompatibility JavaVersion.VERSION_1_8
    26.     }
    27. }
    28.  
    29. dependencies {
    30.  
    31.     implementation 'androidx.appcompat:appcompat:1.3.1'
    32.     implementation 'com.google.android.material:material:1.4.0'
    33.     implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    34.     testImplementation 'junit:junit:4.+'
    35.     androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    36.     androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    37. }
    I would be very grateful if anyone could point me in the right direction here.
    Thank you in advance!
    /Robin
     
  2. robinpalmqvist

    robinpalmqvist

    Joined:
    Feb 15, 2017
    Posts:
    4
    Here is some additional info regarding the issue:

    When I deploy the application as a standalone app (not launching through Unity) on the quest it launches my Activity and displays my layout perfectly fine. This makes me believe that it has something to do with not exiting the fullscreen VR-mode and not being able to make the transition to display my "2D"-layout.

    Ive been running it in several different configurations and cannot seem to get it working. One of the messages from logcat that may have some relevance to this is:

    Code (CSharp):
    1. W ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@16ea560
    But from the posts I have read regarding this i do not understand if it in fact relates to my issues.

    Br
    /Robin
     
  3. MasterGrimald

    MasterGrimald

    Joined:
    Nov 3, 2021
    Posts:
    8
    Hey! Faced the same problem. Have you solved it?
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,060
    Did you update the oculus integration to the latest version?
     
  5. MasterGrimald

    MasterGrimald

    Joined:
    Nov 3, 2021
    Posts:
    8
    Yes, I tried to update the Unity and Oculus integration to the latest versions, but the result is the same.

    As an experiment, I tried to call a function from my Android Native Plugin, which should display a regular Android Toast, but it also doesn't work out (doesn't appear). But if call a simple function implemented in the plugin (e.x. multiplication function), then the logs contain the result of its execution. That is, the plugin is connected and working =(
     
  6. robinpalmqvist

    robinpalmqvist

    Joined:
    Feb 15, 2017
    Posts:
    4
    Unfortunetaly not.
    I, like you did, could also verify the plugin was working logically, it was the part of displaying the new activity that was failing.
    Br
    /Robin
     
  7. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,060
    Did you also update the Oculus XR plugin to the latest version manually? (preferably pre-release)
    And make sure in XR Management, under android 'start XR on startup' is on and Oculus is selected under the android tab
     
  8. MasterGrimald

    MasterGrimald

    Joined:
    Nov 3, 2021
    Posts:
    8
    I tried Oculus XR Plugin 1.10.0 and 2.0.0-preview.1 and XR Plugin Management 4.2.0 and 4.0.7. And Oculus is selected under the Android and PC tab.
     
  9. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,060
    Hmm weird bugs. Updated Unity to the latest v? If so, make a bug report :)
    You can also try to download the VR preset and see if that works and then continue from there
     
  10. MasterGrimald

    MasterGrimald

    Joined:
    Nov 3, 2021
    Posts:
    8
    Perhaps the problem lies in the logs, but I'm in the Unity recently and I couldn't google where to dig.
    This is logs, when I try to start Android Activity from my Test plugin
    upload_2021-11-15_13-24-30.png
     
  11. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,060
    Guessing something with the Android Java proxy or native plugin is failing. Is the native android plugin necessary?
     
  12. MasterGrimald

    MasterGrimald

    Joined:
    Nov 3, 2021
    Posts:
    8
    Yes, this is my main task to launch a native Android app (specially edited) on the Oculus Quest 2.
    I am doing minimal research on this matter, created a primitive native Android Kotlin plugin and launched it just on the Oculus using Unity. Everything works.
    Build project for Oculus and got the problem described above =(
     
  13. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,060
    I still don't understand why you use Unity if it's a native app, sorry if I'm missing something, I have no experience with native development
     
  14. MasterGrimald

    MasterGrimald

    Joined:
    Nov 3, 2021
    Posts:
    8
    Since the Oculus has an Android OS (with some restrictions) and there was a request from management to try to run a native Android app on it.
    I managed to launch the native Android app on the Oculus without any problems, but in windowed mode. And the task arose to get rid of the windowed mode. And for this it is necessary to build the project under the Oculus.

    P.s. I have a lot of experience in writing native apps, but I've been dealing with Unity for about a week =)
     
  15. MasterGrimald

    MasterGrimald

    Joined:
    Nov 3, 2021
    Posts:
    8
    In the end, did you abandon this idea or somehow achieved a similar result by other means?
     
  16. robinpalmqvist

    robinpalmqvist

    Joined:
    Feb 15, 2017
    Posts:
    4
    Hi!
    I needed to abandon the original idea. No matter what I tried, I could not get it working displaying my new activity on the Oculus Quest.

    For my use case it was not absolutely necessary (but preferable) if it would have worked but there were ways I could achieve my goal from within Unity.
     
  17. MasterGrimald

    MasterGrimald

    Joined:
    Nov 3, 2021
    Posts:
    8
    Got it, it's a pity that it didn't work. Also decided to abandon this concept. It remains to explain it to management =)

    Perhaps today I found the reason for this behavior (mobile-vrapi):
    "Multiple Android activities that live in the same address space can cooperatively use the VrApi. However, only one activity can be in VR mode at a time."
    Maybe not, but it looks like our case.

    Best regards!
     
  18. kumarashwin2522

    kumarashwin2522

    Joined:
    Feb 3, 2022
    Posts:
    1
    first of all, you should check for the XR plugin management is installed or not, if it is installed please ensure the check mark in front of the oculus is checked. and try to build it if still, you are facing the same issue then check for particular scenes and if there is any script in that scene make sure there is no error in that, and in the last change the project name. you issue should resolve by this.
     
    Gene92 likes this.
  19. Radicals270

    Radicals270

    Joined:
    Jun 14, 2020
    Posts:
    13
    Legend!! That was it, thank you!
     
    DevDunk likes this.
  20. Tyke18

    Tyke18

    Joined:
    Oct 6, 2023
    Posts:
    16
    bit late to the thread but just saying thanks as you just helped me out too.
     
    Radicals270 likes this.