Start foreground service without popping up a notification in android - android

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.

Related

Lock Screen and Status Bar hangs with foreground service notification

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.

How the android application knows when the heads up notification disappears?

We need to display the heads up notification when our application receives a notification and application is running in foreground. If application receives any other notifications while the current notification is in display, we need to queue the notifications, pop it from the queue and display it when the current notification disappears. Since the heads up notification automatically disappears from screen (remains visible in the notification drawer), I am not sure how our application knows when the heads up notification disappears from screen. Is there any event our application receives? Can any one please let me know if there is any mechanism to know when the heads up notification disappears?

How to increase duration of heads up for Android notification

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).

Service.startForeground() forces the notification to be ongoing, is there a workaround?

When I show a notification via service.startForeground(id, notification), the notification is set to be ongoing, which makes the app cumbersome to use. Is there a workaround to make a foreground notification non-ongoing so that it can be easily swiped away?
If not, I guess I would have to choose between using a background service or adding a "dismiss" action to the notification, which already contains some actions.

How to receive Parse push notification only when app is opened, and show it in modal dialog form

I was using https://github.com/ParsePlatform/PushTutorial sample code for a while.
Current example behavior is
Push notification will be received, either the app is opened or closed.
Push notification is in the form of showing icon in status bar with sound.
I cannot find a way to specific notification icon image. Parse is using app icon as notification icon by default. By Android design guideline requires us to have different style and size for notification icon.
When the app is opened, and notification received. Clicking on the notification icon will cause 2nd instance of the same app is launched. That's mean, there will be 2 instances of same app. (Personally, I don't feel this is a correct behavior)
I was wondering
How can I only receive the push notification when app is opened, but not closed?
How can I show it in the form of modal dialog, instance of showing icon in status bar with sound?
I am not sure about the 4th point, it didn't work that way for me. It opened the same instance for me. I think you are using a different application identifier and have two different application with same name and icon, but different identifier.
Now, for your use case, I think Push notification is not the ideal solution. Depending on what and how frequent you need to show this, you may opt for a repeating pull from the server or if you still want to use Push Notification then subscribe/unsubscribe from a Push Notification Channel when the app is pulled to foreground or background.
ie, when the application is in foreground (onStart() / onResume()), subscribe to a channel:
PushService.subscribe(context, "foregroundPush", YourActivity.class);
and when the application is moving to background (onStop() / onResume() / onDestroy() ), unsubscribe from the same channel:
PushService.unsubscribe(context, "foregroundPush", YourActivity.class);
Whenever you need to send a push notification to the devices with your application in foreground, use the channel 'foregroundPush'

Categories

Resources