android-service

How to stop an Android Service ONLY when there are no other activities in my app running?

孤街浪徒 提交于 2019-12-29 06:34:47
问题 Is there a way I can test if there are any other activities in my app still alive? I am looking to stop a service in an onDestroy method, but only want to do this if there are no other activities from my app still alive on the stack. I have the call stop the service in the main activity's onDestroy() method. This works perfect EXCEPT that if a user launches my app, then launches a few activities in my app, then hits the home screen and RELAUNCHES my app, they will subvert my order and the

Can I prevent Host Card Emulation service from being triggered by select AID?

≡放荡痞女 提交于 2019-12-29 01:26:49
问题 I have an Android app with a service registered to Android beam and a service registered to host card emulation. I want to decide when to enable/disable the HCE service in the code. The HCE service in the manifest looks like this - <service android:name="com.bimo.verifonewallet.service.MyHostApduService" android:exported="true" android:permission="android.permission.BIND_NFC_SERVICE" > <intent-filter> <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" /> </intent-filter

Set a Listener in a Service-based Class

老子叫甜甜 提交于 2019-12-28 12:45:14
问题 Hy i have a problem to set the ServiceUpdateUIListener in the service to update the UI. It's wrong to make a new Service object and set there the listener and put it in an intent. Code source is at http://developerlife.com/tutorials/?p=356 there i can't find how the set the listener and start the service right. Calling: TimerService service = new TimerService(); TimerService.setUpdateListener(new ServiceUpdateUIListener() { @Override public void updateUI(String time) { clock.setText(time); }

How to register a custom speech recognition service?

喜夏-厌秋 提交于 2019-12-28 11:56:12
问题 I created a simple speech recognition service: for this purpose I created a subclass of android.speech.RecognitionService and I created an activity to start and stop this service. My custom speech recognition service trivially uses the default speech recognizer, because my goal is simply to understand how the RecognitionService and RecognitionService.Callback classes work. public class SimpleVoiceService extends RecognitionService { private SpeechRecognizer m_EngineSR; @Override public void

Background Service getting killed in android

强颜欢笑 提交于 2019-12-28 02:24:09
问题 We have developed an Android Application which involves a service in the background. To implement this background service we have used IntentService . We want the application to poll the server every 60 seconds . So in the IntentService , the server is polled in a while loop. At the end of the while loop we have used Thread.sleep(60000) so that the next iteration starts only after 60 seconds. But in the Logcat , I see that sometimes it takes the application more than 5 minutes to wake up

BroadcastReceiver when wifi or 3g network state changed

帅比萌擦擦* 提交于 2019-12-27 10:56:28
问题 I have an app which updates the database whenever the phone is connected to WiFi. I have implemented a Service and BroadcastReceiver which will run the Service (it will tell me what network is in use), but the problem is I don't know what to add in the manifest file to start BroadcastReceiver when the network state changes or when it connects to some kind of network 回答1: You need <intent-filter> <action android:name="android.net.wifi.WIFI_STATE_CHANGED"/> <action android:name="android.net

BroadcastReceiver when wifi or 3g network state changed

混江龙づ霸主 提交于 2019-12-27 10:54:16
问题 I have an app which updates the database whenever the phone is connected to WiFi. I have implemented a Service and BroadcastReceiver which will run the Service (it will tell me what network is in use), but the problem is I don't know what to add in the manifest file to start BroadcastReceiver when the network state changes or when it connects to some kind of network 回答1: You need <intent-filter> <action android:name="android.net.wifi.WIFI_STATE_CHANGED"/> <action android:name="android.net

Broadcast Receiver within a Service

半世苍凉 提交于 2019-12-27 10:45:08
问题 I am trying to start up a BroadcastReceiver within a Service . What I am trying to do is have a background running service going that collects incoming text messages, and logs incoming phone calls. I figured the best way to go about this is to have a service running that incorporates a broadcast receiver that can catalog either. How do i go about doing this? I already have my service up and running. 回答1: as your service is already setup, simply add a broadcast receiver in your service:

Broadcast Receiver within a Service

a 夏天 提交于 2019-12-27 10:44:22
问题 I am trying to start up a BroadcastReceiver within a Service . What I am trying to do is have a background running service going that collects incoming text messages, and logs incoming phone calls. I figured the best way to go about this is to have a service running that incorporates a broadcast receiver that can catalog either. How do i go about doing this? I already have my service up and running. 回答1: as your service is already setup, simply add a broadcast receiver in your service:

Android 8.0: java.lang.IllegalStateException: Not allowed to start service Intent

依然范特西╮ 提交于 2019-12-27 09:07:52
问题 On application launch, app starts the service that should to do some network task. After targeting API level 26, my application fails to start service on Android 8.0 on background. Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=my.app.tt/com.my.service }: app is in background uid UidRecord{90372b1 u0a136 CEM idle procs:1 seq(0,0,0)} as I understand it related to: Background execution limits The startService() method now throws an IllegalStateException if