Number as icon of notification Android - java

my problem seems be without (smart) solution... please help
I'm working on app that update a persistent notification with temp and weather description.
The problem is that I want show current temp in notification bar but
mNotification = new Notification.Builder(ctx)
.setTicker(number);
this code show but with auto-hide, the only value data still persist in bar it's smallIcon.
The problem is that setSmallIcon() want a resource (int) to work, this is carzy, there are other options?
I don't want put inside app 100 or more little images with number, it's no sense...
Thank you

No it is not possible according to the current android notification design principle. You are only allowed to add text in the notification area/status bar.

Related

Custom notification like Inshorts

I want to create a custom notification like inshorts as shown in Image below
And i am able to achieve that as well, shown in screenshot below :
But there are two problem cases:
When i install the app using Android Studio, initially it works fine i.e. Custom Notification layout is displayed for the notification(as shown in picture-3), but when i am killing the app from task manager and then i am sending the notification, it comes as default layout(as shown in picture-4).
When i install the app using the apk on any device, i am getting the notification style as default notification(as shown in picture-4).
I have been stuck in this for long and have changed the whole code of Notification, i am still facing the issue. I am not sure where i am doing wrong.
Picture-3
Picture-4
I was able to achieve what i was looking for i.e. I was looking forward to use the custom layout for showing Notifications eveytime, but the problem was that i was getting custom layout notification if the app used to be in the background and the default notification style when the app is not in the background.
"So what exactly the problem was, Push notifications behave differently in the cases where the app is in background or foreground."
When the app used to be in background the Notification builder code which i have written was being used and the notification with custom layout was displayed. Moreover, when the app used to be in foreground, the android system couldn't reach the notification builder code of my project, in that case notifications were being processed by the Google Service process, which uses the default notification layout.
Solution :
Earlier, the JSON object which i was getting from the server was named as "notification", which generally is used by almost every developer. Changing the name of that JSON object to "data" did the magic.
And the code inside the Notification builder used to be something like this:
String notTitle = remoteMessage.getData().get("title");
which ealier used to be:
String notTitle = remoteMessage.getNotification().getTitle();
This way, my notifications are always being handled by the app, by the NotificationService, and not by the Google Service process.
I hope this helps somebody. :)

Creating a Custom Notification Bar in Android

I need to get started with it.
What I want to do is create a notification bar(like Omega, Status Bar).
I really have no idea from where to get started.
I don't need any code(I try to make my own new code,however long it take), but idea to do it.
I want bar to have many many more features hence I need to create one from scratch.
Also, I want that whenever application's(other) want to show a notification it should come on mine bar.

Close notification event in Vaadin Window

I am writing an application in Vaadin that searches for results. A form is used to specify the criteria and a table is used to represent the results.
I also want to show the amount of results found in a Window.Notification of Vaadin.
My problem is that I want the notification to stay there until the user clicks on it so it does not disappear after a few seconds.
If you just enter a large delay time, then if you don't click on these notifications and do several searches, all result notifications will come over each other. So if you then click on them to remove them, you will see the amount of results from your previous search.
This is what I want to avoid.
Notifications are added to the Window and as far as I can see, you can't get a reference to them to update them. So you can't change the current notification if there is already one present. After it is painted it is removed from the LinkedList<Notification> notifications of com.vaadin.ui.Window
One of the things I was looking at is how Vaadin closes the notification after you click on it so that maybe I can do the same before each search so that the previous notification is removed and the new search adds a new notification.
But so far I am unable to find how it is done.
A notification in html is shown as a div. So maybe there is a javascript I could call in Vaadin to remove that div?
Does anyone know how the timer works for closing the notification after the defined delay? Will this call a javascript that I could also call?
If the delay on the notification is -1, it has to be clicked on by the user. Unless the notification is of type TYPE_ERROR_MESSAGE, you have to create a notification object yourself:
Notification message = new Notification("Message", Notification.TYPE_HUMANIZED_MESSAGE);
message.setDelayMsec(-1);
getWindow().showNotification(message);
There is no mechanism in Vaadin to listen for hide events of notifications. You could create your own widget derived from VNotification to transmit this condition back to the server.

Making an Android App (Java) 'Wait' Until Something Finishes

I have this app that originally has you take a picture, shows you a progress bar, and uploads it to a website.
What I want to add is something so that before the progress bar shows, an Intent starts an activity that loads a layout with a dropdown menu that allows you to choose a descriptor for the picture. Following this, once you hit the 'OK' button on this new layout, the program should return back to where it had left off and display the progress bar.
Does anyone have any ideas on how to achieve this?
It seems that all I really want is some way to tell the program to stall for a while to call an intent, and when the user hits 'OK', the code may resume.
You should be using OnActivityResult().. More information on the link below http://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)

Empty red circle in Android notification status bar!

When I have a status bar notification with a number inside, it shows the number fine. But later if I show another notification to replace this one, with no number, it shows an empty red circle. This circle shouldn't be there. How do I remove the red circle? See image here: http://jump.fm/UYHGV
I've already tried:
notification.number = 0;
and
notification.number = -1;
And forget about canceling notifications first. Since there's no way to query the notification service for existing notifications, I can't detect if the previous one needs to be updated. If I would cancel every time I notify, the user will see the status bar flashing once in a while, which is annoying.
Please advise.
Emmanuel
Hope this help http://code.google.com/p/android/issues/detail?id=7891

Categories