android-service

Is an android service guaranteed to call onDestroy()?

◇◆丶佛笑我妖孽 提交于 2019-11-26 20:22:38
The life cycle diagram of an Activity on an android does not guarantee that onDestroy() would be called, but that the process may be killed and the Activity is removed abruptly. The life cycle diagram of a Service on an android does guarantee that onDestroy() would be called. So I have two questions relating to this difference. Firstly, if the Service is part of the same process as the Activity, is the Service onDestroy() called, though the Activity onDestroy() is not called? I would think not, as "killing a process" suggest that the operating system is stopping its threads and releasing its

Android Library Manifest vs. App Manifest

ⅰ亾dé卋堺 提交于 2019-11-26 20:19:41
问题 I've read similar questions here, but am still not clear on a couple of things. Using a Library Project means that my overall project will have two manifests -- one for the library and the other for the "main" app project -- and I'm not clear what goes in which or if there is some redundancy. I'm developing an app widget with "lite" and "paid" versions, so will have almost all code in a library project. Being a widget, the library will have at least a receiver, a service, a configuration

How to monitor SIM state change

僤鯓⒐⒋嵵緔 提交于 2019-11-26 19:51:14
I'd like to be able to do some stuff when the SIM state change, i.e. play a sound when SIM PIN is required, but I think there are no Broadcast events that can be intercepted by a broadcast receiver for this... registering for android.intent.action .PHONE_STATE does only tell you when the CALL-STATE changes.. An alternative can be starting a service that registers a PhoneStateListener and reacts upon a LISTEN_SERVICE_STATE (when the state is OUT-OF-STATE it can get the SIM state from the TelephonyManager and look if the state is SIM_STATE_PIN_REQUIRED). So, my questions are: 1) Is there any

The process of the service is killed after the application is removed from the application tray

假如想象 提交于 2019-11-26 19:47:30
I am starting a service (or re-starting the running service) when an activity is launched, using : Intent intent = new Intent(this, MyService.class); startService(intent); Later on based on certain actions, the same activity binds to the service using bindService(new Intent(this, MyService.class), mConnection, Context.BIND_AUTO_CREATE); And when the activity is destroyed, I call unbindService(mConnection); Earlier, the service used to restart when I killed the same activity/application from the application tray and showed the "message 1 process 1 service running" under running apps. Now, the

Wake locks android service recurring

半腔热情 提交于 2019-11-26 19:47:08
问题 I have this application that needs to run a service (background) that beeps periodically. The phone needs to beep the entire day for 5 seconds every one minute (used a handler in the service). I have implemented this service which does this perfectly, but when the phone goes into deep sleep mode, the execution stops of this handler stops. Using this answer from the question in SO, I managed to use wake locks and it works fine. But when I explicitly put the phone in deep sleep mode, the

Android Activity with no GUI

有些话、适合烂在心里 提交于 2019-11-26 19:24:19
问题 I have created a activity that is only meant to be launched from a link (using a intent filter.) I do not want this activity to have a GUI - I just want it to start a service and put a notification in the bar. I have tried to put the intent filter for the link in my service, but that does not work. Is there a better thing to do this that will answer to intent filters - or can I just make my activity not have a GUI? Sorry if I'm being confusing, Isaac 回答1: Your best bet would seem to be using

Asynctask vs Thread vs Services vs Loader

旧街凉风 提交于 2019-11-26 19:08:47
问题 I got slightly confused about the differences between Asynctask , Thread , Service , Loader in Android. I know how it works. But i still don't understand what and when should i use. I work with Android for 3 years, and generally still use AsyncTask for all background tasks (and sometimes Thread). But many people say that "Asynctask is outdated", and don't recommend to use them. Also they recommend to use robospice or Volley. So, is AsyncTask really so bad and i should use framework for

Background service for android oreo

主宰稳场 提交于 2019-11-26 18:59:45
How to continue background service in android Oreo without showing notification dot? i continues my background service using notification but i don't want to show notification for running service. Abdur Rahman This isn't possible in this API version (26) and higher. Android OS automatically close your service if you run it without showing a notification to the user. If you are targeting API >= 26 the system will impose a restriction on your service to run in background unless your activity in foreground. As soon as your activity goes to background, the service will be terminates when system

Repeating Alarm Manager After reboot

≯℡__Kan透↙ 提交于 2019-11-26 18:34:59
问题 i want to create broadcast AlarmManager(repeating) with Notification message.i pass my calender object from Pickers. If i don't reboot my device it works normally. However, when i reboot my device,as you know my calander object will be null. How can i manage my repeating alarm after rebooting and how can i hold my Calendar schedules? Thanks for your ideas. public class MyReceiver extends BroadcastReceiver { private static final int PERIOD = 10000; final public static String ALARM_ID =

Android onCreate or onStartCommand for starting service

非 Y 不嫁゛ 提交于 2019-11-26 18:29:56
Usually when I create an Android service I implement the onCreate method, but in my last project this does not work. I tried implementing onStartCommand , and this seems to work. The question is: when I have to implement a service which method is required? Which methods I have to implement? onCreate , onStartCommand , or both? And what is the role of each? onCreate() is called when the Service object is instantiated (ie: when the service is created ). You should do things in this method that you need to do only once (ie: initialize some variables, etc.). onCreate() will only ever be called