I'm writing an application for my Android phone. The application has a background service. I want to display that service in the notification area like Skype application does.
If I use NotificationManager and Notification (the way android samples do), the result is different.
See this image
My notification is the one called "Service".
The Skype service has an icon just above the notification area. Skype has also "normal notifications". These "normal notifications" appear below my notification.
I want my service to be above the notification area like Skype application is. Does anyone know how to do that?
Thanks in advance.
Take a look at
http://developer.android.com/reference/android/app/Notification.html#FLAG_ONGOING_EVENT
Also look at
Android: How to create an "Ongoing" notification?
and
http://developer.android.com/guide/topics/ui/notifiers/notifications.html
Related
I am building an social media app in Android studio, this app uses firebase for push notifications, and notifications is working fine, that Is notifications shows on device's notification bar.
How can I change the behavior so that the notification can appear as popup when app is in foreground?
I want a persistent kind of notification, something like WhatsApp that can stay on top other apps so that users can quickly open notification on wherever they are on their phone.
On my research, the best i could get was to use this on my theme
But I do not have Theme.Holo.Dialog in my style and my aim is that the notification should appear even if app is not open.
Thank you for looking into this
You should use heads-up notifications
For this purposes you should use notification channel with high a importance: How to set importance in the notification channel.
In this answer you can find code sample, how to show notification in the channel with high importance(to show notification even if the app in the foreground):
https://stackoverflow.com/a/67953864/16210149
Hope it would be helpful.
On my Android 10 device, I see that the LastPass app is able to create a "Persistent notification". As seen in this screenshot below:
I have an application which I want to have a persistent notification for running my foreground service. But after all attempts, I don't get the the same observation as the LastPass app with saying its a "persistent notification". It just shows just as a "notification".
Does anyone know how to do this? Does anyone know if it really matters?
On my Android 10 device, I see that the LastPass app is able to create a "Persistent notification". As seen in this screenshot below:
That is not a "persistent" notification - that is a notification channel, which LastPass has apparently opted to call "Persistent notifications" for whatever reason.
I have an application which I want to have a persistent notification for running my foreground service.
Sounds like you want an ongoing notification.
Hope that helps!
Just make setOngoing true. It will be persistance.
NotificationCompat.
Builder(context, CHANNEL_ID)
.setOngoing(true)
This is the first time I am integrating notifications into my application. I am using Firebase. Setup was extremely simple and I am able to view the notification in the tray.
So, when the application is open, and if it receives a notification. I would like to display the notification in the activity itself.
How should I go about this?
You can look at Gmail approach. If there is new mail in current thread, they show SnackBar with notification.
You need to determinate connected parts of your app. And if notification connected to part where current user is - show SnackBar, and if there is something completely different - show heads-up notification.
Guide how to do Heads-Up notifications here
Guide how to do SnackBar notifications here
Have you ever tried Pushbots , its an infra- Structure for Notifications , it has more interesting Features than Firebase. Give it a shot.
Pushbots link
I'd like to know if it is possible in Android 4.3+ to have an app which can create a notification of another app.
For example: I develop an app, say myApp, with a button. Every time I tap on that button a new notification from another app, say Telegram, is triggered.
I'm sorry I don't have any code to show you as a start point nor a POC, but I really can't find anything useful on the web.
No it is not possible. Unless you have some communication channel that generates a new notification. For example:
You have developed a messaging app X that when receives a message produces a notification.
You have developed an application Y that sends a message to the application X.
You can pop a noti with whatever info you want. But you want to say, notify of a new mms or gmail, then no
I am looking at Avast, Lookout for example and I am trying to understand the concept of the implementation. So it is more like asking for direction for me.
Persistent App icon in Notification bar.
Am I correct to say there are function NotificationManager is able to do it?
Scan virus during app installation, I am not interested in virus scanning but the triggering mechanism.
Some kind of Android service bind to the main app?
Main app that can be bring up in the Notification menu.
A main app that remain trigger action to the bind services?
So what do I need to read to understand? NoticationManager, Services and ??
In short, I want to load a icon in the notification bar that can bring up my app. There is a background service that perform specific task for a set interval.
Yep, NotificationManager and Notification can help you with that.
You just need to create the notification with flag FLAG_ONGOING_EVENT (to make it persistent). Even better if your service IS REALLY performing some long-running task, if so, you can start your service via Service.startForeground which needs some 'ongoing' notification for running (notification is required to notify the user that there is some work going now).
For triggering app install event, you can use BroadcastReceiver with filter by Intent.ACTION_PACKAGE_ADDED.