android - Which background model to run -
I'm trying to develop an application that requires background play services. I'm relatively new to Android programming, and after reading books to create and manage many posts, blogs, how and services, I'm still quite confused about which model I should try to use. First of all, I present the application's requirements (normally): I need an application that will create a background process that will be connected to the Bluetooth device. I Bluetooth device Android The device is designed to deliver data. The issue is that the data can arrive at any time, so the Bluetooth connection needs to be active. Note that the app is a very special app and it is not for public use. I understand logic to run background apps at all times, but please understand that this is a very specific application for a very specific client.
Now, in general, I think the program will flow to launch the application (and launch a UI activity) then I need to configure and connect with the Bluetooth device. At this time, the user should be able to do other things - make a phone call, check their email, etc., while the Bluetooth connection is still active and potentially getting data. If the data comes, a notification is removed, etc.
So here are my questions and concerns:
-
If I had an app (which UI activity and finally my Bluetooth connection service) but killed the app Obviously, the service dealing with Bluetooth connections is also killed, how can I keep it alive? I have read that Service.setForeground () was depricated, but even if I was done to set it in the foreground, if the app is killed, also killed as a service, I need to run it in the background The higher the priority (again, I think this is considered a "bad form", but this is a specific app and this functionality has been requested by the customer).
-
If I have started an app (and service etc.), but users say, answer phone calls, then the app is kept in the background, though That user goes back to the home screen and starts a different example of the app, i.e., he does not hold the home key to select the app that is already running from the task manager, but completely launches a new one is. If the service that handles Bluetooth connections is still running, how will this new instance behave? That is, how can I get to connect it to Bluetooth service, which is running in the first instance of the app instead of this new instance? Do I have to use a remote service instead of a local service? This is where I am confused with things because it defines remote services and AIDL seems to be a lot more overhead, and since I already had a lot of overhead with the background running service I want to keep it as small as possible. How can I insure that I am already running the same service? > 1) This service does not depend on a
activity
as long as you do not call onstopSelf ()
, you can run on the background.You can listen to
android.intent.action.BOOT_COMPLETED
> So your service is started when the phone is on.2) Your
activity
must be linked to the service and check out the information about it.
Comments
Post a Comment