32071

Notification doesn't show up if only large icon is set

Question:

I want to add a large icon to my notification, but when I run the app, the notification doesn't show up.

When I change to small icon, it works but icon is too small.

Below is my code, any help where it is wrong?

Bitmap rawBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setLargeIcon(rawBitmap) .setContentTitle("Alert") .setContentText("CITRUS PUNCH Minute Maid expired"); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(1, mBuilder.build());

Answer1:

Per the <a href="http://developer.android.com/guide/topics/ui/notifiers/notifications.html#Required" rel="nofollow">notification guide list of required fields</a>, you <strong>must</strong> set a small icon via the <a href="http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setSmallIcon(int)" rel="nofollow">setSmallIcon()</a> method. Generally, this icon looks like your application icon, although entirely as white over a transparent background per the <a href="http://developer.android.com/design/style/iconography.html#notification" rel="nofollow">notification iconography guide</a>: tools such as the <a href="http://romannurik.github.io/AndroidAssetStudio/icons-notification.html" rel="nofollow">Notification Icon Generator</a> may help in building an appropriate small icon.

On Android 5.0+ devices, you can use <a href="http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setColor(int)" rel="nofollow">setColor()</a> to set a branded background color for behind your small icon.

Large icons are <em>not</em> meant for branding purposes - instead, they should be used to <a href="http://developer.android.com/design/patterns/notifications.html#MakeItPersonal" rel="nofollow">make it personal</a> and be an image associated with the sender of the notification (i.e., a profile picture) or additional information to convey the meaning of the notification.

Recommend

  • Puzzle in Prolog
  • How do I make this formula support multiple rows/dragging?
  • OpenGL ES Startup
  • My hashes are stacking unordered..What's a loop that can select them by their Hash ID?
  • jquery conflict not running two jquery in same page
  • How to access variables in a (citrus) static-response-adapter
  • Getting Parse Push Notification in List view
  • NotificationManager Error Android Studio
  • Group notifications on Android
  • Can't synchronize call to notify()
  • JavaFX Dialogs remove header decoration
  • how to get date and month column using object model database in android
  • why toast message not showing in marshmallow 6.0.1 while showing it lower than 6.0
  • BroadcastReceiver cannot show notification when app closed/killed
  • Launch activity when user taps on a notification from the lockscreen
  • VBScript/IIS - How do I automatically set ASP.NET version for a particular website
  • Push Notification not proper - Android
  • Is it possible to set an Android Notification or a later date and time that will fire when the app i
  • UIPickerView without IB?
  • Cassandra NoClassDefFoundError: com/google/common/util/concurrent/AsyncFunction
  • SqlCommand back up Database
  • Execute scripts AJAX returns
  • How to use JavaScript to determine whether a file exists in a directory?
  • Functions in global context
  • FileReader+canvas image loading problem
  • Ajax jQuery multiple calls at the same time - long wait for answer and not able to cancel
  • How do I fake an specific browser client when using Java's Net library?
  • Date difference with leap year
  • angularjs unit test when to use $rootScope.$new()
  • Volusion's generic SQL folder, functionality
  • Menu Color Fade on Hover with Jquery
  • How to limit post in wp_query
  • Hazelcast - OperationTimeoutException
  • How to make Safari send if-modified-since header?
  • Adding custom controls to a full screen movie
  • Compare two NSDates in iPhone
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • reshape alternating columns in less time and using less memory