This question has been asked before, but has not been properly answered yet. I know this is possible but we're feeling a little confused.
We need to display custom/dynamic images in the status bar when push notifications are received. We're concerned with the larger image seen in the pull-down, not the small image in the actual status bar. Because they need to be dynamic, the images can not be packaged with the apk and we are trying to target Android 2.2
What we're trying to achieve is similar to how Facebook displays the profile image of the user who initiated the notification in the notification bar. It's also similar to how whatsApp shows the group image in the notification bar when a new push notification arrives.
From what we've read, this is possible only in Android 3+, sdk 11. But that can't be true.
We've installed both Facebook and WhatsApp on an Android phone running 2.3.4 and sure enough, custom icons display in the notification bar.
So what's the secret? How do they do it? How can we do it?
so what you are trying to do is set the setLargeIcon(Bitmap icon) in the notification builder. This is available in APi 11 and above (honeycomb). The notification builder in the compatibility package v9 can set it for you, but it will only appear on api 11 and above.
To achieve the same effect in 2.3 and below you must create a custom notification layout and set it with setContent(RemoteViews views) in Notification.Builder to generate a custom layout. This can be styled with a large icon on the left side to imitate the > API 11 styles.
Creating custom layouts is tricky and many things have to be taken into account, such as available screen size on other devices to display the notification, and themed text colors (especially as notifications used to be dark text on white bg, now they are light text on dark bg) There plenty of guides and even SO posts that can help you out (such as this one)
In regards to getting a dynamic image, when the phone receives the message (push notification or whatever) and your app goes to build the notification, you can do a small http request to pull a dynamic image before building the notification. This will delay the posting a few seconds, but it doesn't really matter. Then you can get the resulting image and use it in the notification. The specific image can be chosen by sending some data with the (im assuming push notification) that identifies what photo, such as a url, or an id that you can append onto an already existing url in your notification building part of the app.
Hope this helps, any followups just ask :)
You can't use anything but prepackaged drawables as your notification icon as seen on status bar. And no, you did not see anything like you look for in FB app (or you talk about notification area seen when you pull it down).
Related
I am having some issues displaying the number of notifications on badges on Android while using expo managed workflow.
I want the badge to update when the app is killed.
On IOS is working fine by setting the badge variable a number but somehow on android i only get a little dot that is telling me that there are unread notifications but no badge is shown.
This is how it should display:
But i am getting only a dot on the icon like on this example:
My question is that by using the badge variable should while sending out push messages from the backend should this be working on android aswell and i am messing something up or do i need another approche on android?
Any suggestions are welcome since i cant find any answer on this and been searching for days now.
Many thanks,
Trix
Android notifications icon works different than on iOS because these are just one color, with transparency.
So when you reference the icon image make sure it has the transparency, if not, all the form is filled.
Also check your app.json to add this:
https://docs.expo.dev/versions/latest/sdk/notifications/#custom-notification-icon-and-colors-android-only
https://docs.expo.dev/versions/latest/config/app/#notification
I wanted to create a question on how to create notification icons for an app. Then answer it.
I will be answering the following questions that I feel need to be grouped together in one explanation rather than spread across the inter web.
FIRST
What is a small icon in notification.builder?
SECOND
What is a large icon in notification.builder?
THIRD
How do I make a small, large icon for notifications?
Small Icon : Icon that will be shown in the status bar when your notification is fired
Large Icon : Icon that will be shown in the notification tray (When slides down). If large icon is missing, then the small icon is used for this purpose.
Refer Notification.Builder for more details.
For creating notification icons, you can use Notification Icon Generator of Android Asset Studio
1.)
To answer the first question we need to understand the design guidelines that Google has graciously made for Android.
GOOGLE DESIGN GUIDELINES
Watch the video that is located in the above link, in the section shown below. It will explain the design behind android's new notifications
A small icon is basically a context to what the app is trying to convey or it can be used to act as the main icon for all notifications, but know that you will not get a filled in SMALL ICON it will always be centered in the circle that is how Google has designed it.
For example I am building an app that will have many different notifications pushed to the user. However, I would like the main app icon to show as a large icon using Bitmap, but to help the users know the context and grow a habit of understanding that notification to be connected with a certain action in the app. The small icon would serve that purpose by providing a simple transparent white image.
A small icon is a completely white transparent image that has the main components of the graphic transparent to be shown on the notification tray, and when slid down.
2.)
Refer to the above link, video for the large icon reference.
A large icon can be the main app icon, or it can be an image downloaded from a data source. Preferably in my situation I use it as the main app icon. However, it can be anything in Facebook, Instagram use images downloaded from their servers to serve as context for who is commenting on a post, then Facebook uses their small icon to represent Facebook. Focusing on the user, rather than the app.
3.)
To make a small icon you will need to either consult a graphics designer or follow the icon size guide here.
For large icons that would depend on what you need exactly. Whether you want to use the app icon itself, or make one a bit more larger for example, Music player shows album art in a big size. Possibly using custom layouts.
Lastly, something I also really struggled with for a few days was the context. I kept getting Null Pointer Exception, and the app would crash. What was happening was I was using a fragment. I was passing context properly, however I was getting the context when the fragment was created, "OnCreate". This works both in fragments and activities. Those that have this issue in an activity do the same make sure your context is being initialized in the OnCreate.
mContext = getActivity(); For Fragments
mContext = MainActivity.this; For Activities
That is it, let me know if you have any questions or concerns. I am sure that I might be missing some info, or not explaining it entirely as Google would, but I was having tons of trouble so I wanted to make sure those that were struggling as I was could have something to help guide them.
I am facing a problem with development a application.
I am using a Cloud Push Notification with Titanium Appcelerator.
I have need display push Notification in Group.
How display this is display in single particular particular tab?
I am sharing 2 images
Currently looking like this.
I have need look like this. How do?
You have to use a Big View Notification Style but it is only available in 4.1 or newer
quote from here:
A notification's big view appears only when the notification is expanded, which happens when the notification is at the top of the notification drawer, or when the user expands the notification with a gesture. Expanded notifications are available starting with Android 4.1.
in the same document, you can find a sample how to use this. there are also som tips/hints how to maintain compatibility with older devices (not only regarded to the big view)
you must put the following code in your TiApp.xml
<property name="acs-grouped-notification-message-" type="string">You have $number$ unread messages.</property>
I want to display the unread count to the application icon. I refer the lots of stack overflow answers for achieving that. All the links are saying that it is not possible. But android Mail, Message application displays the unread count at the top of the icon and in some links says that use widget instead of icons. But I don't know how to use the widget instead of icon displays in android application.
Like the above image I want to display unread count in my application icon.
Unfortunately, You can't do that on application icon. Android doesn't allow that.
But you can do that using widget.
There are many question related this, check it first.
Question 1
Question 2
Question 3
Widget Example
Widget Link
Update : 24/04/2015
Now this is possible for some launcher app.
Check this ShortcutBadger and BadgeUtils
Update
Android allow Modify a Notification Badge from Android 8.0 (PI level 26).
Showing Badge in application icon is not allowed by default in Android. We can do this in some of the customized devices available in android:
Below are the links how we can show on some Device like Sony,Samsung etc.
https://github.com/leolin310148/ShortcutBadger
Utility Class I found on git:- will be helpful also
https://gist.github.com/Tadas44/cdae2f5995f21bf1c27f
And for rest of the Non customized devices we can create a custom widget to reflect this same behaviour.
See How to create Widget:
https://looksok.wordpress.com/2012/12/15/android-complete-widget-tutorial-including-source-code/
currently I'm working on an UI Replacement of Android, currently achived by writing a different launcher and different-styled apps. All's good so far, BUT: there is still the notification bar missing, means, I have no idea how to replace the notification bar.
The "new" notification bar shall show only generic informations like the clock and network state, similar to windows phone and ios, without NotificationManager-binding.
How can I achive this? I know that there are several notification bar replacement apps out there, like omega statusbar or statusbar+.
My idea was to make every app of my UI fullscreen and having its own NotificationBar-Instance, fed by a ContentProvider or Service. But if the user decides to use classic android apps, he also will see the generic notification bar, which isn't what I want.
Also it might be an idea to create a window on top the notification bar, but I have no clue either this is "the right way", nor if it is even possible to achive this in this way.