10-29-2024 06:36 AM
Hi, I am trying to build a simple hybrid app but the problem is as soon as I resize my window, it goes completely black.
here is the Basic MainActivity:
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
App()
}
}
}
@Composable
fun App() {
Column {
Text("Hello World!", color = Color.White)
}
}
and here is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:horizonos="http://schemas.horizonos/sdk">
<horizonos:uses-horizonos-sdk
horizonos:minSdkVersion="69"
horizonos:targetSdkVersion="69"
/>
<uses-feature
android:name="android.hardware.vr.headtracking"
android:required="true"
/>
<uses-feature
android:name="oculus.software.handtracking"
android:required="false"
/>
<uses-permission android:name="com.oculus.permission.HAND_TRACKING" />
<uses-feature
android:name="com.oculus.experimental.enabled"
android:required="true"
/>
<uses-feature
android:name="com.oculus.feature.PASSTHROUGH"
android:required="false"
/>
<uses-feature
android:name="com.oculus.feature.VIRTUAL_KEYBOARD"
android:required="false"
/>
<uses-feature
android:name="oculus.software.vr.app.hybrid"
android:required="false"
/>
<uses-feature android:glEsVersion="0x00030001" />
<uses-feature
android:name="oculus.software.overlay_keyboard"
android:required="false"
/>
<uses-feature
android:name="com.oculus.feature.RENDER_MODEL"
android:required="false"
/>
<uses-permission android:name="com.oculus.permission.RENDER_MODEL" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:label="@string/app_name"
android:theme="@style/Theme.PanelAppThemeTransparent"
android:supportsRtl="true">
<meta-data
android:name="com.oculus.supportedDevices"
android:value="quest2|questpro|quest3"
/>
<meta-data
android:name="com.oculus.handtracking.version"
android:value="V2.0"
/>
<meta-data android:name="com.oculus.vr.focusaware" android:value="true" />
<uses-native-library
android:name="libossdk.oculus.so"
android:required="true"
/>
<activity
android:name=".MainActivity"
android:exported="true"
android:screenOrientation="landscape">
<meta-data android:name="com.oculus.vrshell.free_resizing_lock_aspect_ratio"
android:value="true" />
<layout android:defaultHeight="800dp" android:defaultWidth="800dp" />
<meta-data
android:name="com.oculus.vrdesktop.control_bar_config"
android:value="{'show_title':false,'show_report_bug':false,'with_back_button':false, 'use_activity_label':false}"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="com.oculus.intent.category.2D" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
10-30-2024 10:47 AM
Hi, to enable resizing, you also need to add the meta-data in the activity's manifest:
<meta-data android:name="com.oculus.vrshell.supports_free_resizing" android:value="true" />
Here's the sample hybrid app for resizing config:
10-30-2024 11:49 PM
This solution does not work on my project.
Here is the screenshot when the app is first launched:App launched
and here is after the window is resized:After window is resized
I am guessing maybe spatial SDK works with XML for initial 2D screen and the Jetpack compose can be embedded only in the 2D panel inside the 3D screen?
10-31-2024 01:04 PM
Hi, I tested it for Jetpack compose with hybrid panel, it works as expected.
It could be the layout issue within your panel. You may want to double check the hybrid app's config and your layout.
Hope these helps:
10-31-2024 02:22 PM
How do you start the app? I had a similar issue, if I start the app using Android Studio or adb, resize would make the app go black. But if I start it from the shell then it works fine.
10-31-2024 11:45 PM
Hi, thank you for your reply. I tried this repo as it is and I still see black screen when resizing the window (Quest 2 v69, Android Studio Ladybug | 2024.2.1 Patch 1):on App Launch
After resizing the window
10-31-2024 11:47 PM
I've been running it from Android Studio. Can you tell me how to start the app from the shell? I tried this command but with same result:
adb shell am start -n com.meta.spatial.samples.hybridsample/com.meta.spatial.samples.hybridsample.Ma
inActivity
11-01-2024 11:19 AM
Sorry, I meant the Meta UI shell 😀. In the headset go to the Applications Library and launch it from there. Or you might already have in the taskbar.
11-26-2024 01:46 AM - edited 11-26-2024 01:48 AM
I had the same issue and fixed by adding the following attributes to the hybrid activity:
android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode"
My activity block ended up looking like this:
<activity
android:name=".HomeActivity"
android:exported="true"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode"
android:screenOrientation="landscape">
<meta-data
android:name="com.oculus.vrshell.supports_free_resizing"
maxSizeX="1600"
maxSizeY="1000"
minSizeX="800"
minSizeY="500"
android:value="true" />
<layout
android:defaultWidth="1100dp"
android:defaultHeight="650dp" />
<meta-data
android:name="com.oculus.vrdesktop.control_bar_config"
android:value="{'show_title':false,'show_report_bug':false,'with_back_button':false, 'use_activity_label':false}" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="com.oculus.intent.category.2D" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Really hope this helps 🙂
12-08-2024 03:42 AM
I'm not exactly sure what worked but now in Quest v71, it seems to be working as expected.