I know we can START_STICKY service or use receiver event for start service in android
I'm making chat app for android with java that this service must be active in
any mode in android
There are many method for keep alive this service
START_STICKY
Use phone event
Start Foreground
But I dont know what is best way for keep alive service and android 8 and other version
You know that for chat app,service must be active always for receive new messages
Thanks
I found best solution
We dont have any problem about alive service in android 7 and lower version
Main problem is in android version 8
We can associate service to BroadcastReceiver in manifest and have alive service always
BroadcastReceiver can be TICK or CONNECTIVIYCHANGED or SCREEN event that when this events
occur so us service started without any problem
Thanks
Related
First of all I don't know what type of code to put for my problem.
I'm developing an Android mobile game, with two ways to earn ruby, via mini transactions or via the OfferWall IronSource.
Regarding the OfferWall, those are tasks to complete to then receive Ruby in exchange.
Now my problem that I would very much like to solve
When a user completes a task and the app is not running, how can I send a notification?
zigg, my suggestion would be to call firebase notification while running background service or you can use push notification as Blundell suggested in background service.
The background service will run even if the app is not running. I use foreground services and call push notification in the service when the app is closed or in background.
Hope this helps.
Currently working on an Android application that enables people to alert other people in the same network that have said app installed on their android device. It uses Java's Network Service Discovery classes to accomplish this.
There's a background android service that advertises a network service to the network, so the device can be seen and communicated with by other devices in the network. It calls
mNsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
to register the service on the network.
This background service runs at all times when the device is connected to a WiFi-network to ensure availability.
All the functionalities that have been implemented work fine, until the phone gets put to sleep.
When that happens the network service, which is supposed to be broadcasted at all times, stops showing up.
I assume this is not a bug, but normal behaviour since the Android background service is stopped(?) and as such stops sending packets to the network when the phone is put to sleep.
How can I solve this issue? Do I need to take a different approach entirely?
I am trying, with programming in Java-Eclipse to get a simple string from my Wi-Fi Server through an http request. The problem is that I want to have that string Info available in an Android Service before the Android Device prompts the user for an entry code, that is before it completes booting up. Is there any way to achieve that with java -Eclipse?
As a normal app? No.
AFAIK, the earliest event a normal app can get is BOOT_COMPLETED which, as its name suggests, happens when the boot is completed.
I realized an android application which always has to remain activated in the background. To make that, it is enough to use a Service which remains active after the user is left the application.
Nevertheless, if the user rebooting, the application as well as the Service will not be any more active.
How to solve this problem?
I think of having an idea with BroadcastReceiver but I am not on whether it is the best solution.
Thanks in Advance.
So you want the service to restart if the phone is rebooted ?
Create a BroadcastReceiver that listens for BOOT_COMPLETE (you need a permission for this). Have it start your service.
Android may stop your service due to lack of memory.If you have onStartCommand return START_STICKY and have your onCreate of the service call startService on itself, you'll restart when memory is available.
You can set up an alarm to wake your service if its not running, and set up a broadcast receiver on boot which will start the service when the device boot.
I'm a newbie to Android development and I'm interested in two things which is connected to Google Cloud Messaging.
Does Android absolutely kill applications if they run for a long time in background as iOS does? And if so will I receive GCM notifications after my app was killed by Android?
Is there some difference between Force Close (from the settings menu) and when the app is killed by Android? And if I do Force Close will I receive GCM notifications?
1 - yes, but if you install in your manifest a broadcast receiver that listens for the gcm, it will triggered anyway. What you will do with that event depends on your app. A common practice is to start an intent service that handles the message. It's up to you to make interact with the activities of your app.
2 - From android 3.1, if the user force closes your app, it will stop to be notified of any broadcast until the user does not start your app again. Check "Launch controls on stopped applications" here for more details.