Browse Source

fix: resolve FloatingUIActivity crash on startup

- Move setupTransparentOverlay() from onCreate to onResume to avoid null window
- Add try-catch block to handle WindowInsetsController access errors
- Add null-safety checks for window operations
- Prevent crash when accessing insetsController before window is ready

Fixes: NullPointerException when accessing WindowInsetsController
Error: 'getWindowInsetsController()' on a null object reference

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
feature/modern-capture-ui
Quildra 5 months ago
parent
commit
19a9a2bbe8
  1. 16
      app/src/main/java/com/quillstudios/pokegoalshelper/ui/FloatingUIActivity.kt

16
app/src/main/java/com/quillstudios/pokegoalshelper/ui/FloatingUIActivity.kt

@ -74,9 +74,6 @@ class FloatingUIActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Make activity transparent and overlay-capable
setupTransparentOverlay()
// Bind to the ScreenCaptureService
bindToScreenCaptureService()
@ -92,6 +89,12 @@ class FloatingUIActivity : ComponentActivity() {
}
}
override fun onResume() {
super.onResume()
// Setup overlay after window is fully initialized
setupTransparentOverlay()
}
override fun onDestroy() {
super.onDestroy()
if (serviceBound) {
@ -101,8 +104,9 @@ class FloatingUIActivity : ComponentActivity() {
}
private fun setupTransparentOverlay() {
try {
// Make the activity transparent and fullscreen
window.apply {
window?.apply {
// Hide system UI (navigation bar, status bar)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
setDecorFitsSystemWindows(false)
@ -139,6 +143,10 @@ class FloatingUIActivity : ComponentActivity() {
setType(WindowManager.LayoutParams.TYPE_PHONE)
}
}
} catch (e: Exception) {
Log.e(TAG, "Error setting up transparent overlay", e)
// Continue without overlay setup if it fails
}
}
private fun bindToScreenCaptureService() {

Loading…
Cancel
Save