intentservice

IntentService responding to dead ResultReceiver

穿精又带淫゛_ 提交于 2019-12-20 14:17:07
问题 An activity instantiates a ResultReceiver and overrides onReceiveResult. The activity then sends an Intent to an IntentService and includes the ResultReceiver as an extra. Once the IntentService is finished processing it sends a message back to the ResultReceiver and processes it in onReceiveResult. The issue is if the user navigates away from the Activity then the result is still sent back to the ResultReceiver which causes all types of issues. Is there not a way to stop this behavior? I've

GCM push notification for background app causes crash

微笑、不失礼 提交于 2019-12-20 04:15:28
问题 I stumbled about a problem to receive GCM messages if my app runs in background (Service). In my scenario, I don't receive the GCM message (please notice it is not about how to receive GCM in general like here) and the ActivityManager kills the app. So I wonder if I have a conceptual misunderstanding or if it is a general problem. Background I have an Android application that runs in foreground (Activity) and background (Service). The application is attached to a persistent notification to

AsyncTask与IntentService

馋奶兔 提交于 2019-12-19 16:58:57
https://blog.csdn.net/qq_35572068/article/details/84961265 https://blog.csdn.net/lxg1234567890/article/details/27048949 Android主线程,也就是UI线程,其最大用途在于运行四大组件以及处理他们和用户的交互。其他耗时操作交给子线程,如网络请求、I/O操作,从Android3.0开始,网络访问必须在子线程中进行,否则将会失败并抛弃异常,避免ANR现象。 AsyncTask是轻量级异步任务类,封装了Thread和Handler。 AsyncTask : onPreExecute(),异步执行之前,此方法被调用做一些准备工作。doInBackground()在线程池中执行,此方法用于执行异步任务。doInBackground()在线程池中执行,此方法用于执行异步任务,执行过程中可以调用publishProgress()方法更新任务执行进度。onProgressUpdate()方法在主线程中执行,每次任务进度更新时被调用。onPostExecute()在任务执行完成时被调用,其参数为doInBackground()的返回参数。 执行顺序与联系如下图 代码Demo: public class DownloadFileAsyncTackDemo extends

How to communicate between background services

Deadly 提交于 2019-12-19 11:36:05
问题 I am implementing an app, in that I have two Services. One does some task and pass some value to another service and that service does some task using this value. When the first Service generate first value it should start 2nd service. Here after the values generated by the first service will be added in a queue in 2nd service. First time when the 2nd service starts I can set the value in queue using intent, but I don't know how to communicate after starting the 2nd service. How to

Failed to resolve Intent Service Android

£可爱£侵袭症+ 提交于 2019-12-18 04:20:44
问题 I am getting following error when trying to configure Push Notification: 06-07 01:05:59.735 18708-18708/com.ebr.apps.ebr.development E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement 06-07 01:05:59.735 18708-18708/com.ebr.apps.ebr.development E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found. I have different flavors in gradle: My code package name is : com.ebr.apps.ebr My product flavor package is: com.ebr.apps.ebr

How to force stop Intent Service in progress?

我只是一个虾纸丫 提交于 2019-12-18 01:08:49
问题 I have an intent service which downloads several gigabytes of videos. I have a "Stop" button, to stop the download if accidentally hit "Start" or whatever. I know this has been asked a couple of times but with no working answer for me. I try to call stopService() , doesn't work. That just calls IntentService.OnDestroy() . I tried to call stopSelf() inside onDestroy , doesn't work either. I tried to have something like a flag, but onHandleIntent doesn't get called if its already running, it

Can an IntentService run indefinitely?

僤鯓⒐⒋嵵緔 提交于 2019-12-17 22:42:47
问题 Based on my understanding, an IntentService will get stopped when its current request is done. Consider the below scenario, i will be triggering a request to the IntentSerivce for every 100ms and the processing time will be 90 ms for that request. So for every my request - startSerivce call, service will get invoked and after 90ms (once the processing is done), onDestroy of the IntentServicee will get invoked. I would like to have this IntentServicee running till i say stop. Is that possible?

Asking an IntentService for information about its queue

懵懂的女人 提交于 2019-12-17 15:58:16
问题 I have an IntentService that queues up web service calls that need to be made to my web server. So each Intent is a web service call to be made. I'd like to set something up where my application can ask this IntentService if it has any Intents containing a particular piece of data (IE: "Are you already waiting to ask the cloud for x data? Or do I need to tell you to do it?"). Are there any suggestions on how I might extend IntentService to do this? Can the Intent queue of an IntentService be

Android开发性能优化总结

南楼画角 提交于 2019-12-15 18:38:13
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Android性能调优包含 移动网络优化 Java(Android)代码优化 布局优化 数据库性能优化 参考链接 http://www.trinea.cn/android/android-traceview/ 本文主要针对代码调优 应用程序的性能问题体现在很多方面, 比如第一次启动速度慢,或者进入某一界面速度慢;动画执行过程不流畅,或者动画执行卡顿时间长;ListView列表滑动过程中卡顿,不流畅;应用程序自定义的某特定界面执行速度慢;响应某一用户事件时长时间无响应(ANR);操作数据库时,执行大量数据的增删改查操作,执行速度慢;文件读写频繁,缓存文件过大导致卡顿;应用长时间运行后,随机出现卡顿现象。 以上的问题的原因可能不只一个,并且很多情况下并不是应用本身的问题,也有可能是系统其他层次有问题,只不过体现在应用层。所以开发人员在处理性能问题时,需要做的第一件事情就是判断是否是应用自身引起的性能问题,然后再对症下药;但有些时候应用本身逻辑正常,但由于系统的硬件配置不足引起了异常,此时就要根据产品或项目需求,采取一些更加精准的方式优化性能,以弥补硬件配置的不足。 以下从几个不同的角度总结一下应用程序性能优化的一些方法。 一、编程思想 应用层的性能优化通常可以从以下几个方面考虑: 了解编程语言的编译原理

Stopping an IntentService from an activity

二次信任 提交于 2019-12-14 03:45:05
问题 I have an IntentSerivce that runs in the background sometimes and it can be quite a long running process in certain instances. I give an option for the user to quit the application which basically just stops and polling and ignores any GCM push notifications. But if a push notification came in and the IntentService is taking a while to finish doing what it has to (gets information from a server and sends a notification to the user if needed, like a new message arrived or something). Here is