I have used foreground service with a custom notification layout. Everytime the notification is present the lock screen and the status bar gets very slow. Everywhere the notification is shown that part of the mobile UI becomes slow. Whenever I open such places phone goes 10Hz display. This happens only in few devices.
Related
An android foreground service needs a notification, which is fine, but I would rather have it go directly to the notification background without first obscuring the UI for 3 seconds.
Is there a combination of settings for the notification builder and or the notification channel, which will give me the small icon in the notification bar as well as the notification, when expanding the notification list, but without showing a notification on top of the ui for about three seconds?
My issue is not that I want to hide anything, but rather that the application is in use by the user after the foreground service is being started, so the popup is annoying.
I am developing a react-native app with a video call feature and need it to display a 'heads up' notification that lasts for 40 seconds when the user receives a call, but the notification only displays for about three seconds before disappearing. I have tried setting the category to 'call' and priority to 'max' on Android 6.0 but to no avail.
An image displaying a notification for an incoming call:
You should use the equivalent to the setFullScreenIntent() API on your notification:
An intent to launch instead of posting the notification to the status bar. Only for use with extremely high-priority notifications demanding the user's immediate attention, such as an incoming phone call or alarm clock that the user has explicitly set to a particular time.
The system UI may choose to display a heads-up notification, instead of launching this intent, while the user is using the device.
When you set a full screen Intent on your Notification, two things happen:
When the screen is off, the activity you've set via the full screen intent is launched instead of the notification being posted.
When the screen is on, your notification will be posted as a heads up notification that will be persistent (it won't collapse to the status bar unlike a normal heads up notification).
I want to display notification even when the screen is locked.
The pre-requisites are :
1.the notification should be displayed when the application is opened(this part I've covered).
2.there is a timer which will run in the background and on locking the screen, while app is running, the timer will start. After certain duration the notification will appear on the screen.
Can please anyone help me with this?
In my app, I have to continuously show status bar notification after some event is triggered. The status bar must glow in red rather than in default background. During that period,I am responsible for recording sound i.e. it is just like recorder but the instead of running in Activity, it will run on Service and the user is notified by blinking status bar in red. The user at any time can go the status bar and stop the recording.And the recording can carry on even when lockscreen is on.
So is it possible to achieve this in Android and if possible could you give us some logic for this implementation.
Consider using a foreground service, which lets you post an ongoing notification. There's no API for changing the color of the entire status bar. You can certainly color your icons, and on JellyBean and later you may be able to change the color of the notification itself using RemoteViews -- that's talked about in this link.
First, do this (tested on Nexus 5 running 4.4.2):
Pass a PRIORITY_LOW notification to Service.startForeground().
Observe notification is not shown in status bar.
Raise a PRIORITY_MAX notification using same notification ID.
Observe notification is shown in status bar.
Now, is there any way to remove that icon from the status bar (other than Service.stopForeground())?
I've tried calling NotificationManager.cancel() and NotificationManager.cancelAll(). And also tried raising the same original PRIORITY_LOW notification. But all of them leave the notification icon in the status bar.
This was changed in Android 4.3, to always show notifications for foreground services.
There is a good reason for this, namely that foreground services cannot be killed when the system needs more resources. If the notification is not there, there is no way for a normal user to know that there is something still running and draining battery.
If you don't want the notification, consider using a background service instead. If you really need a foreground service, the user have the right to know.
Read more on http://commonsware.com/blog/2013/07/30/notifications-foreground-services-android-4p3.html
One workaround is to call Service.stopForeground() followed by Service.startForeground().