Notification icons template for Android? - android

Is there any tutorial about how to design a good icon to put in the status bar as a notification in an Android App?
Ideally I'm looking for a template or an icon that I can easily modify. I'm not a designer.
I need smiley faces status bar icons.

You can download icons from the buzzbox sdk resources page:
http://hub.buzzbox.com/android-sdk/notification-icons
there is also a photoshop file you can download and modify.
There is also one simple status bar template icon in the official template pack from Android
http://developer.android.com/guide/practices/ui_guidelines/icon_design.html#templatespack

Here is the information straight from the Android Developer's Page: http://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html
This also contains a link to the icon template pack

Check out the Android Asset Studio! It's a great tool for creating a number of Android icons, including notification icons.

Notification notification = new Notification(R.drawable.asterisk_sign, text, System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0); //this is how we will launch an Activity when the user clicks the notification
notification.setLatestEventInfo(this, getText(R.string.app_name), text, contentIntent);
mNM.notify(R.string.minutemaid_service_started, notification); //send the notification to the system, to be displayed in the notification bar
this is an example of how to make a notification in the notification bar that starts an activity when selected.

Related

android 7.0 Notification icon appearing white square

I am using the below snippet to generate notifications in my android app.
private void sendNotification(String contentText, String message) {
Intent resultIntent = new Intent(this, MainActivity.class);
resultIntent.putExtra("clear","clear");
resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent piResult = PendingIntent.getActivity(this, 0, resultIntent,0);
NotificationCompat.Builder builder=new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.icon)
.setColor(ContextCompat.getColor(getApplicationContext(),R.color.red))
.setContentTitle("title")
.setContentText(message)
.setAutoCancel(true)
.setLargeIcon(BitmapFactory.decodeResource(getResources()
,R.drawable.notification))
.setContentIntent(piResult);
NotificationCompat.InboxStyle notification = new NotificationCompat.InboxStyle(builder);
int i;
for(i=0; i<messageList.size();i++){
notification.addLine(messageList.get(i));
}
notification.setBigContentTitle("title");
notification.setSummaryText(contentText);
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID,notification.build());
}
It works in android 5 and 6 but for android nougat it is not working
Following the docs from the Android API:
Status bar icons are composed simply of white pixels on a transparent backdrop, with alpha blending used for smooth edges and internal texture where appropriate.
Your whole image but the transparent parts is going to be converted to white (being originally white or having colors).
One solution is to create a silhouette icon with color, by this way you can use the same image in all Android APIs. One example could be this icon:
In lower versions of Android you would see the black face, in the last versions you will see the same face but with white color. That's because of the transparent parts (it seems SO removes the transparency, you can get the original from here) of the image.
From android version lollpop onwards, they have made the changes for the notifications. When you are specifing the small icon, it should be of specific size as mentioned in this link.
The important thing is the image should be transparent and contains only white color.
You can check this question to get the answer
According to this blog here
It says that
You’ll note that the icons are not present in the new notifications; instead more room is provided for the labels themselves in the constrained space of the notification shade. However, the notification action icons are still required and continue to be used on older versions of Android and on devices such as Android Wear.
If you’ve been building your notification with NotificationCompat.Builder and the standard styles available to you there, you’ll get the new look and feel by default with no code changes required.

Strange "oo" Notification Area icon instead of ic_stat_notify in Android

I am trying to set an alarm notification icon in the Notification
Area doing this:
Notification notification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_notify)
.setCategory(CATEGORY_SERVICE)
.setContentTitle("Service")
.setContentText("Alarm is ON").build();
I made my icon in Android Studio using File -> New -> Image Asset -> "Notification Icon" then choosing a pre-defined clip-art.
The strage thing is, in the Notification Drawer I get the ic_launcer icon
and in the Notification Area I get the trange "oo" icon you can see on the
left side of the image below.
picture of my Notification Area
Have you every seen this? Do you know how to fix it? The phone on which
I am testing is a Meizu U20, Android 6.

Android notification displays wrong icon

I have a static Array with Icon ids:
public static final int[][] ICON_IDS = { {R.drawable.ic_access_alarm_black_24dp, R.drawable.ic_access_time_black_24dp, R.drawable.ic_account_box_black_24dp, R.drawable.ic_add_black_24dp, R.drawable.ic_android_black_24dp, R.drawable.ic_clear_black_24dp, R.drawable.ic_delete_black_24dp },
{ R.drawable.ic_settings_black_24dp, R.drawable.ic_airplanemode_active_black_24dp, R.drawable.ic_filter_list_black_24dp, R.drawable.ic_account_box_black_24dp, R.drawable.ic_airline_seat_individual_suite_black_24dp, R.drawable.ic_delete_black_open_24dp, R.drawable.ic_delete_black_open_24dp}};
I display all the icons and the user can choose one. The id of the chosen icon is passed to the notification manager. It displays the notification like this:
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(notification.getIconId())
.setContentTitle(notification.getTitle());
I have checked with an "test-ImageView" that the id is correct. The ImageView displays the icon the user selected (with setImageResource(notification.getIconId());). But on the notification in the notification bar another icon is displayed or none.
If I use .setLargeIcon() it shows the correct icon again.
.setLargeIcon(BitmapFactory.decodeResource(getResources(), notification.getIconId()))
But only in the big icon. The small icon is empty.
The icons are the material icons imported via vector assets.
What is wrong with this?
Found out why. You can't use xml resources as Notification Icons.

setSmallIcon() dynamically when receiving notification?

This is for a general notification app. I've managed to capture and set the large icon for the notification since it accepts a Bitmap type as a parameter, but setting the small icon is proving to be a lot more tricky. It only accepts an int resource ID. Since I have no idea what application might be sending a notification to my listener, I would have to generate it dynamically. I can get the small icon by listening for incoming notifications and extracting it, but I can't seem to find a way to set it via its resource ID.
I don't think it's possible, but just want to confirm. If so, is there a workaround, or would I have to manually load small icons of specific apps I want to support into my Drawable folder and then use the resource Id from there? That sounds like a hassle seeing that I've already gotten the right icon, but can't load it in! Below is my code:
public class NotificationService extends NotificationListenerService {
#Override
public void onNotificationPosted(StatusBarNotification sbn) {
Bundle extras = sbn.getNotification().extras;
int id1 = extras.getInt(Notification.EXTRA_SMALL_ICON);;
//Building Notifications
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context.getApplicationContext(id1))
.setSmallIcon(R.mipmap.ic_launcher) //This gives an error
.setContentTitle("My Title")
.setContentText("My Text");
NotificationManager notificationManager =
(NotificationManager) context.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(notiId, mBuilder.build());
}
}
Small icon might not load if it exceeds the size prescribed by Android.Generally we can load small icons through images stored in resource folder only.
can get the details regarding icon sizes for push notifications from the following link
GCM Push Notification Large Icon size
Small Icons in push notifications cannot be added dynamically. Large Icons can be added dynamically by running an Async task. Application will crash if there is no small icon. Small Icon is mandatory for PushNotification.

Set status bar icon names

I'm about to publish my first application. I created all the necessary icons, in my case the launcher icons and the status icons (which I only created for my app next versions updates).
But I am wondering where the status icons names are set. I mean, the launcher icon name is set in the Manifest file this way :
android:icon="#drawable/ic_launcher"
so is there a similar place to set the status icon name?
Thanks in advance!
I'm pretty sure you explicitly set the icon when you make a notification. So:
int icon = R.drawable.notification_icon;
CharSequence tickerText = "Your Text";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
This was taken directly from http://developer.android.com/guide/topics/ui/notifiers/notifications.html

Categories

Resources