Skip to content

Cannot start forground services and using activity!!.startservice(intent) causes app crash even if not null #5

@EiTaNBaRiBoA

Description

@EiTaNBaRiBoA

The issue comes when working with notification System for android cengiz-pz and kyoz when the app is on pause due to OS the notification broadcast will work for several seconds untill os will kill it (even if battery optimization is disabled).

So a solution for that will be creating a foregroundservice and binding to it.
but when doing activity (which i get from oncreate) and using it to startService() or startForegroundService() or bindService() , it cause the app to crash.

private fun serviceAction(pActivity: Activity?) {
    Log.d(TAG,"Start Service")
    val newIntent: Intent = Intent(this, RunningService::class.java).also { it.action = "Start"}
    val componentName = pActivity.startForegroundService(newIntent)
    pActivity.bindService(newIntent, mViewModel.getServiceConnection(), Context.BIND_AUTO_CREATE)
}

Godot android plugin doesn't implement ViewModelStoreOwner and LifecycleOwner which makes it hard to work with mvvm. when binding to the serviceconnection

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions