My app run from Android 5.0+. I am currently testing my app on a Android 9 device.
I have a service that acts as a client.
I have tried starting the service with both startService and startForeground but it didn't change the outcome (I didn't display any notification in the status bar though). I've noticed that those Services who also draw over other apps won't be killed after few minutes, instead services that only execute background code are being stopped shortly after. Why is that?
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.
How can i show calling screen with accept/reject button when my app will receive call from admin side(back-end) when app is in background or killed state. Is their any way to achieve this? My app requirement is,it can only receive Video Call from back-end, i'm using OpenTok for video call. App is working fine when it is in visible state. I'm able to show calling screen with both buttons. But when app is in background or killed than unable to handle this. I'm getting push when call initiated from admin side.
I am doing some investigation on Google Play Location Service
Google Play Location Samples
I am experiment the following issue on LocationUpdatesForegroundService sample application: the app process is still running after closing the app.
Steps to reproduce it:
Open app
Press "request location updates" button
Press device home button for sending application in background
Close the app
My expectation is that the app process (and all its threads) has to be stopped but it does not.
The app process is still running after closing the app
It happens when I close the app after calling
startForeground(NOTIFICATION_ID, getNotification());
How can avoid it?
It looks related with the foreground service for collecting location.
How can I stop the service while the app is closing?
As per the documentation the Service is the Android component which run continues in background even if the app is closed.
If you want to stop service when app is remove from recent task(i.e app kill) you have to used android:stopWithTask="true" in AndroidMenifest.xml for explicitly closed the service.
Example ,
<service
android:name=".LocationUpdatesForegroundService"
android:stopWithTask="true" />
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
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.