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 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.
I'm making an application, Let's see what i want to do actually. I executed my code using react-native run-android and my home screen is active now. Then i went to the background and locked my phone using lock key of the mobile phone. then i'm sending notification to the app, the notification is being showing in the phone but the screen is still locked, home screen is still inactive. I want to awake my phone on receiving notification and i have used react-native-firebase for push notification.
Thank You.
I had tried to make it using react-native-keep-awake.
On receiving the notification, My code is KeepAwake.activate() but its not awaking my screen.
react-native-keep-awake will only work when the app is in foreground. What it does is that it simulates the manual touch to keep awake feature. Especially used in video player apps and navigation apps when the app is in foreground and you do not want to get the screen get automatically locked.
I am creating an application with push notification alerts using Google C2DM service. Can i blink the phone screen with some colors on push notification events if the phone screen is dark out?
Get a WakeLock (developer.android.com/reference/android/os/PowerManager.html) and start off an Activity
I’m having a weird problem with notifications.
I have created an on going notification, and I want to sometimes update the notification and display a new ticker text.
When I create the notification, the ticker text is correctly displayed.
When I update the notification the first time (with the code below), the new ticker text is correctly displayed.
When I update the notification the second time, with exactly the same code and the same arguments as the first time (in particular the same new ticker text), the ticker text is not displayed.
Where is the problem?
Code:
mNotification.tickerText = newTickerText;
mNotification.when = System.currentTimeMillis();
mNotification.setLatestEventInfo(activity, title, message, pIntent); // I don’t think these arguments are relevant, but I can post more code if you want
nm.notify(42, mNotification); // nm is the NotificationManager
Edit:
Ok, I found the cause, Android does not want to display the ticker text again if it is the same as before.
Is there a workaround for that?
Edit #2:
My application is a multiplayer game, I have to keep a network socket open during the time the user is connected.
But I do not want to abruptly disconnect the user when he receives a new SMS and wants to read it (for example). What I want is to have the on going notification saying something like "You will be disconnected in 30 seconds".
I have the problem above when the user is connected, leave the application, come back less than 30 seconds after, and then leave the application again. I repeatedly flash the same message only if the user repeatedly leaves and come back to my application (which shouldn’t occur often, I guess)
Do you think this could harass the user? What should I do instead?
Is there a workaround for that?
Have meaningfully different text that the user will value. Do not harass the user by repeatedly flashing the same message.
UPDATE based on edit
What I want is to have the on going notification saying something like "You will be disconnected in 30 seconds".
That's fine.
I have the problem above when the user is connected, leave the application, come back less than 30 seconds after, and then leave the application again.
The user came back to your activity, which is where you should be canceling the Notification, in which case you will have no problem re-displaying the same ticker message.
You could have two different ongoing notification codes - one for when user is using application, one when user is left. Then when user starts your application, you cancel your "inactive" notification and display "active" notification. And when user leaves again, just cancel "active" notification and display "inactive". This way you should always get ticker when displaying "inactive" notification. If both notifications have the same icon, user might not even notice. When connection terminates, just hide both notifications, so user will know he's offline.