intentservice

onHandleIntent() - Wallpaper change not working correctly

你。 提交于 2020-01-06 10:17:54
问题 I am using the IntentService to change wallpaper in the background. Using the code below inside the main Activity class the wallpaper changes to an image correctly, but when the code is added to the onHandleItent() the background changes to a different solid color each time. Is this a memory issue or what? Code inside Activity class - works correctly: public void ChangeWallpaper(String imagepath) { DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay()

onHandleIntent() - Wallpaper change not working correctly

笑着哭i 提交于 2020-01-06 10:17:06
问题 I am using the IntentService to change wallpaper in the background. Using the code below inside the main Activity class the wallpaper changes to an image correctly, but when the code is added to the onHandleItent() the background changes to a different solid color each time. Is this a memory issue or what? Code inside Activity class - works correctly: public void ChangeWallpaper(String imagepath) { DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay()

Android: Nested Intent Service Not Being Started After Call to Context.startService()

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-04 01:56:29
问题 My nested intent services is defined as follows: package com.my.package; ... // Bunch of imports public class MyNotifier ... // Bunch of variables public class MissedCallIntentService extends IntentService { private static final String TAG = "MissedCallIntentService"; public MissedCallIntentService() { super("MissedCallIntentService"); Log.i(TAG, "Creating intent service."); } @Override public void onHandleIntent(Intent intent) { Log.i(TAG, "Handling intent service."); } } // Test my nested

Manually ending the IntentService worker thread

我只是一个虾纸丫 提交于 2020-01-03 18:36:35
问题 I am having some trouble manually ending the IntentService onHandleIntent method. I am catching an exception which is crucial to the execution of the rest of the thread and I want to stop the thread as i catch the exception. I tried calling stopSelf() or directly calling onDestroy() which I'm sure are probably very bad ways of doing it, and they aren't working. The thread calls them and then continues. Anyone have any good ideas of how to do this? 回答1: As sonykuba said, finishing the

AlarmManager Stops after removing app from recents apps

廉价感情. 提交于 2020-01-02 20:44:20
问题 I am new to this part of android, and here I aim to use alarm manager to run a code snippet every 2 minute which will poll a server (using the website's api) and based on the returned JSON generate notification. After a looking up the web I thought one of the best option in my case will be using intent service and android. Manifest of Services and Recievers <service android:name=".NotifyService" android:enabled="true" android:exported="false" > </service> <receiver android:name=".TheReceiver"

Android: Toast from IntentService remains on screen for ever

*爱你&永不变心* 提交于 2020-01-02 07:32:33
问题 I checked this question, but it doesn't appear to answer my problem, which is much less involved. I am calling an IntentService from a menu item in my main process. It is currently just a skeleton which puts up a Toast in onHandleIntent() which eventually should appear briefly at the end of the processing to say it's finished. However it remains on the screen for ever (even when the application is stopped). I tested both with the emulator and my Galaxy S2 with identical results. Can someone

AsyncTask executed from Service (IntentService) and Activity - is there a difference?

好久不见. 提交于 2020-01-02 07:31:30
问题 Is there any difference between AsyncSync being fired up from Activity or IntentService? I'm building an app which downloads and uploads files via http. I use custom notification layout with progress bar for each transfer. I choose between doing transfers in parallel or putting them into queue (which option would you recommend?). For the option with queue I use an IntentService, so Android framework takes care of putting tasks into a queue for me. For having them in parallel I use AsyncTasks.

Keeping alive Intent Service after application is killed

。_饼干妹妹 提交于 2020-01-02 01:15:10
问题 I have intent service in my app. This service has some job to do - uploading some files. It runs only when there is something to do. Service won't upload when some conditions are met, for example no Internet connection. For that reason it registers itself to on broadcast receiver to receive message about Internet connection changes. The problem is that service is killed with app even if it is doing something, for example: App is sending intent to service Service started uploading something,

Android Download Multiple Files one after another and show progress in ListView

◇◆丶佛笑我妖孽 提交于 2020-01-01 15:53:48
问题 The user can add any number of downloads, but download will start one after another i.e. next download will start only after the completion of present download. The user will navigate away from the activity showing download progress in order to add new downloads, and when new file to be downloaded is added, the application navigates back to the activity showing download progress, where it will show the progress of the download, previously added, and keep the presently added file as pending

多线程(四)、Android多线程使用及AsyncTask源码分析

半城伤御伤魂 提交于 2020-01-01 00:59:19
本篇是多线程系列的第四篇,如果对前三篇感兴趣的也可以去看看。 多线程(一)、基础概念及notify()和wait()的使用 多线程(二)、内置锁 synchronized 多线程(三)、线程池 ThreadPoolExecutor 知识点总结 除了前面的线程池的使用外,在Android中,我们除了通过 Thread 创建线程外,还可以通过 AsyncTask 、 IntentService 、 HandleThread 来创建,线程池前面一篇已经详细介绍了,下面对其他几个方法简单的介绍。 1.1、HandleThread 1.1.1、源码 public class HandlerThread extends Thread { int mPriority; int mTid = - 1 ; Looper mLooper; public HandlerThread (String name) { super (name); mPriority = Process.THREAD_PRIORITY_DEFAULT; } public HandlerThread (String name, int priority) { super (name); mPriority = priority; } protected void onLooperPrepared () { } @Override