Tag: android service

为什么unregisterReceiver()永远不会调用onServiceDisconnected?

我绑定到我的活动中的服务: override fun onStart() { Timber.d("onStart") super.onStart() val intent = Intent(this, MyService::class.java) bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE) } 迄今为止工作。 然后bindService()调用onServiceConnected() : /** Defines callbacks for service binding, passed to bindService() */ private val serviceConnection = object : ServiceConnection { override fun onServiceConnected(className: ComponentName, service: IBinder) { // We've bound to MyService, cast the IBinder and get MyService […]

Android:活动重叠另一个应用程序

我需要一些帮助来指导我在一个项目中,我需要我的应用程序识别另一个应用程序何时开始,然后我的活动出现。 我研究了服务,intentservice和broadcastreceiver。 但我不知道如何执行我的想法。 你们可以推荐我一些职位,书籍,教程吗? PS:我熟悉Java和Kotlin

在Android服务中的Kotlin协程

我有一个android服务,它启动并同步服务器上的不同类型的数据,当它在线。 我是Kotlin协程新手,我试图完成以下任务: fun syncData{ //Job1 make retrofit call to server //Job2 make retrofit call to server after job1 is done. //Job3 make retrofit call to server after job 2 is done and so on. //After all jobs are done I'll stop service. } 我正在关注这篇文章: Kotlin Coroutines是Android的正确方法 这给我带来了这个解决方案 fun syncData() = async(CommonPool){ try{ val sync1 = […]