Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
EiTaNBaRiBoA opened this issue May 17, 2024 · 0 comments

Comments

@EiTaNBaRiBoA
Copy link

EiTaNBaRiBoA commented May 17, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant