I am trying to customise the System UI Navigation Bar using Jetpack Compose. Unlike ordinary applications which have access to Activity
or Fragment
s, the navigation bar is modified by implementing the OverlayPlugin
(interface link) and declaring it in the AndroidManifest.xml
file (code below taken from this link) as a Service.
<service android:name=".SampleOverlayPlugin"
android:label="@string/plugin_label"
android:exported="false">
<intent-filter>
<action android:name="com.android.systemui.action.PLUGIN_OVERLAY" />
</intent-filter>
when using the context provided, I get the following error:
“Tried to access the API:ViewConfiguration which needs to have proper configuration from a non-UI
Context:com.android.documentsui.DocumentsApplication@608ad35 The API:ViewConfiguration needs a proper configuration. Use UI contexts such as an activity or a context created via createWindowContext(Display, int, Bundle) or createConfigurationContext(Configuration) with a proper configuration.
java.lang.IllegalAccessException: Tried to access the API:ViewConfiguration which needs to have proper configuration from a non-UI Context:com.android.documentsui.DocumentsApplication@608ad35”.
I have tried solutions similar to:
- InputMethodService with Jetpack Compose – ComposeView causes: Composed into the View which doesn’t propagate ViewTreeLifecycleOwner
- https://www.techyourchance.com/jetpack-compose-inside-android-service/
but to no avail.