intentservice

Subscribing or binding to an existing Intent service

て烟熏妆下的殇ゞ 提交于 2019-12-04 03:26:36
问题 I have an app that has an initial activty that list some files within a list view. When an item is clicked within the list it takes you to a detail activity of that specific file. In the detail view I have a button called download, when you click on download it starts a IntentService which sets off the file to be downloaded as such: downloadButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(AppDetailsActivity.this, AppDownloadService

What happen when my Activity is destroyed when I'm using IntentService with ResultReceiver

≯℡__Kan透↙ 提交于 2019-12-04 03:02:32
I have searched through the net to find this answer. But no result found. Sorry that I'm a very newbie in Java & Android programming. I would elaborate on my question more. Let say my Activity started an IntentService and it's running independently in the background. The service is "subscribed" to the callback of ResultReceiver to update the Activity UI. And during the service is executing the long running process, the Activity is destroyed. So what will happen if the service send a reply or progress update to the Activity via the ResultReceiver ? Cause as I know, the ResultReceiver need to

How to correctly handle startForegrounds two notifications

我是研究僧i 提交于 2019-12-04 01:00:01
问题 I have an IntentService that uploads a file. Everything works fine, but I'm a little confused about how to handle the notifications. When I start the notification I use startForeground() because the files can be rather large and I don't want the upload to get killed unless absolutely necessary. When I use startForeground() it displays two notifications in the notification area (one under Ongoing and one under Notifications): I've read through a number of different Stack Overflow posts and web

how to receive data from service when fragment is resumed?

老子叫甜甜 提交于 2019-12-03 18:18:27
问题 I have a side menu drawer in my activity that has 2 options ("My files" and "Sync"), each of which is a fragment. When I am in "Sync" fragment, there is a button to start downloading files from the server. This is done through an intent service which is running in the background. I use a result receiver in my fragment which keeps getting the download progress (%) from the service and displays it in the fragment. The problem is that if I switch to the "My Files" fragment while the download is

Prevent Android “process is bad” error

北慕城南 提交于 2019-12-03 15:43:46
问题 The process is bad error does not seem to be very well documented, and I have only been able to find workarounds. I am instead interested in the cause of this error and how to prevent it from happening, and not how to manually handle it through rebooting, relaunching app, etc. My particular application uses an AlarmManager to launch an IntentService which runs for ~10s every ~30s. This is called on creation of the application: Intent serviceIntent = new Intent(appContext, MyService.class);

What is the difference between service, intentService in android? [duplicate]

筅森魡賤 提交于 2019-12-03 14:48:50
问题 This question already has answers here : Service vs IntentService (11 answers) Closed last year . What is the difference between Service and an IntentService in Android? What is the difference between AsyncTask and an IntentService in Android? 回答1: 1. Difference between Service and IntentService Service : It is the base class for the Android services, that you can extend for creating any service. Since the service run inside the UI thread, it requires that you create a working thread for

Notification created by IntentService uses always a wrong Intent

白昼怎懂夜的黑 提交于 2019-12-03 10:43:02
问题 Problem When the user presses Send "Button 1" (scroll down to see the construction of the app) a new Notification is created from the RefreshService . If the user presses this notification a MainActivity instance gets started and receives a String with the value Button 1 over the Intent. This value gets displayed. When the user presses now the Send "Button 2" a new Notification is created from the RefreshService . If the user presses this notification a MainActivity instance gets started and

IntentService won't show Toast

一世执手 提交于 2019-12-03 09:33:23
This IntentService I created will show Toasts in onStartCommand() and in onDestroy(), but not in onHandleIntent(). Am I missing something about the limitations of an IntentService? public class MyService extends IntentService { private static final String TAG = "MyService"; public MyService(){ super("MyService"); } @Override protected void onHandleIntent(Intent intent) { cycle(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show(); //This happens! return super.onStartCommand(intent,flags,startId); }

23 个重难点突破,带你吃透 Service 知识点「长达 1W+ 字」

有些话、适合烂在心里 提交于 2019-12-03 09:28:33
前言 学 Android 有一段时间了,想必不少人也和我一样,平时经常东学西凑,感觉知识点有些凌乱难成体系。所以趁着这几天忙里偷闲,把学的东西归纳下,捋捋思路。 这篇文章主要针对 Service 相关的知识点,进行详细的梳理,祝大家食用愉快! 文章目录 方便大家学习,我在 GitHub 建立了 仓库 仓库内容与博客同步更新。由于我在 稀土掘金 简书 CSDN 博客园 等站点,都有新内容发布。所以大家可以直接关注该仓库,以免错过精彩内容! 仓库地址: 超级干货!精心归纳 Android 、 JVM 、算法等,各位帅气的老铁支持一下!给个 Star ! # 第一篇:Service 是什么 1.1 什么是 Service Service (服务) 是一个一种可以在后台执行长时间运行操作而没有用户界面的应用组件。 服务可由其他应用组件启动(如 Activity ),服务一旦被启动将在后台一直运行,即使启动服务的组件( Activity )已销毁也不受影响。 此外,组件可以绑定到服务,以与之进行交互,甚至是执行进程间通信 ( IPC )。 1.2 Service 通常总是称之为 “后台服务” 其中 “后台” 一词是相对于前台而言的,具体是指:其本身的运行并不依赖于用户可视的 UI 界面 因此,从实际业务需求上来理解, Service 的适用场景应该具备以下条件: 并不依赖于用户可视的 UI

Android IntentService won't start on boot

陌路散爱 提交于 2019-12-03 09:10:25
I have an IntentService which starts on boot and stays running in the background. There is no launcher Activity, the IntentService is called by a broadcast receiver. It works on 2.3.4 and 4.0.4 devices but not on 4.2.2. Maybe my broadcast receiver isn't being triggered on the device? Manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="br.com.xxx" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <uses-permission android:name="android.permission.ACCESS