android-service

Can you use a LoaderManager from a Service?

为君一笑 提交于 2019-11-27 00:41:59
问题 I have a data loading system set up using a custom Loader and Cursor that is working great from Activities and Fragments but there is no LoaderManager (that I can find) in Service. Does anyone know why LoaderManager was excluded from Service? If not is there a way around this? 回答1: Does anyone know why LoaderManager was excluded from Service? As stated in the other answer, LoaderManager was explicitly designed to manage Loaders through the lifecycles of Acivities and Fragments . Since

BroadcastReceiver dies with app

断了今生、忘了曾经 提交于 2019-11-26 23:41:46
问题 If i let the phone sit for a long time like 15 minutes i lose my receiver but i thought it was to persist like a service after being killed for memory. Manifest: <receiver android:name=".WearableReceiver" android:enabled="false"> <intent-filter> <action android:name="com.example.johnbravado.MESSAGE_PROCESSED"/> </intent-filter> </receiver> In Activity to start receiver ComponentName component = new ComponentName(CounterActivity.this, WearableReceiver.class); getPackageManager()

Background service pause and start again automatically on OREO

走远了吗. 提交于 2019-11-26 23:39:56
问题 I have created a background service for registering SCREEN_ON and SCREEN_OFF intent to catch an event using broadcast receiver but some time due to unknown reason my service does not pass intent to my main application. For testing i have generated log file using ten second timer that it is my background service working or not. Which i have attached below. I got a issue that my background service pause some time and start it automatically. It is my background service public class

Send Data from Service To Activity Android

*爱你&永不变心* 提交于 2019-11-26 23:03:42
问题 I am building a music player that uses a service for playback. I have an Activity UI that controls (play, pause, next, ...) the service. I want to update the UI from my service when the next or previous button is pressed. I thought of passing an integer value. Here is my code: I have used a messenger for communication. The code in my service looks like: enum Event { NextSongChanged, CurrentPlayingSong }; public synchronized void registerHandler(Messenger m) { clients.add(m); } private void

Android - Firebase jobdispatcher

戏子无情 提交于 2019-11-26 22:51:12
问题 I would like to know if it's possible to use Firebase jobdispatcher to schedule an url hit and get the response in order to update the db. I would like it to run once per day at night. Does anyone know if this is possible? I can't find any good example of doing this. I already read android documentation and https://github.com/firebase/firebase-jobdispatcher-android#user-content-firebase-jobdispatcher- . I need to use Firebase jobdispatcher because I'm targeting API 16. Thanks in advance.

Cannot keep android service alive after app is closed

不想你离开。 提交于 2019-11-26 22:44:13
问题 I am trying to spawn a service that stays alive all the time, even if the user closes the application. According to these threads Keep location service alive when the app is closed Android Service Stops When App Is Closed Android: keep Service running when app is killed this can be accomplished with IntentServices or Service.START_STICKY Yet, I tried both types of services without success. In other words, my services get killed when the app is closed by the user. Can someone point out if this

Control the default music player of android or any other music player

纵饮孤独 提交于 2019-11-26 22:02:46
How to control the default music player of android or any other player? By controlling i mean pause, play, next etc. Do i have to bind the service? I have tried to use the IMediaPlaybackService but it is not working. There is certainly a way out as i have seen apps in the android market which controls the music player. Any idea? Ahmed Ekri AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); if(mAudioManager.isMusicActive()) { Intent i = new Intent(SERVICECMD); i.putExtra(CMDNAME , CMDSTOP ); YourApplicationClass.this.sendBroadcast(i); } you can by getting the

keepRunning PhoneGap/Cordova

自闭症网瘾萝莉.ら 提交于 2019-11-26 21:53:23
问题 Anyone can explain me how keepRunning works in the config.xml for Android. I mean, I don't want to know how to write the instruction but how does it work, how does it affect the execution of the Android app ? Does it create an Service in background ? If anyone can find the source where we can see how does it work, that will be great Thanks. Edit : I try to analyze the generated code, analyze the RAM, services and processus in the setting of Android. And my conclusion is..... that do nothing.

How to keep my app service keep running even if app is closed from task manager in MI phone

淺唱寂寞╮ 提交于 2019-11-26 21:03:13
问题 My app has background service which keep on running even if app is killed from the task manager but when I have tested my app on MI(xiaomi) phone it kills my app service when I close the app from task manager and my service keep on running and work perfectly on all devices except MI even if I kill my app from task manager. So how to keep my service running in background even when the app is killed from the task manager? 回答1: MIUI has a built-in Security app. In the Security app there is a

Android L (API 21) - java.lang.IllegalArgumentException: Service Intent must be explicit

岁酱吖の 提交于 2019-11-26 20:57:16
Android new version - "Lollipop" (API 21) brings quite a few changes with it, but it comes with some price if you wish to target your app to that API. When we started adapting our apps to the new API, one of the first problems we've encountered is the IllegalArgumentException: Service Intent must be explicit If you have encountered the problem, and you are actually intending to use your intent in explicit way (meaning that when starting the service you are expecting to hit exactly 1 service action), here's a quick fix for turning implicit --> explicit: public static Intent