I need to create a Notification with a longer text, is that possible? By default it is not, but you can use a custom layout, which is what I did. Now I can display multiple lines, but as you can see, the text is still broken / not displayed completely? ): Can someone please tell me what I am doing wrong / if there's a fixed limit for the size of notifications? If you look at the screenshot you will notice, that there is still a lot of space left... Thanks for any hint!
BTW here's the XML used for the custom layout, based on http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomNotification
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="3dp" > <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginRight="10dp" /> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="fill_parent" android:textColor="#000" /> </LinearLayout>
If you have multiple push providers you will need create your own Messaging Service to handle push notifications. You will need to pass new tokens to Swrve and make sure Swrve is set to handle incoming notifications.
Set the unique id to let Notification Manager knows this is a another notification instead of same notification. If you use the same unique Id for each notification, the Notification Manager will assume that is same notification and would replace the previous notification.
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_notification) .setContentTitle(title) .setStyle(new NotificationCompat.BigTextStyle() .bigText(message)) .setContentText(message) .setDefaults(NotificationCompat.DEFAULT_SOUND) .setContentIntent(contentIntent) .setAutoCancel(true); mNotificationManager.notify(requestID, mBuilder.build());
once reffer https://developer.android.com/guide/topics/ui/notifiers/notifications.html
For Jelly Bean and higher you can use an expandable notification. The easiest way is to use the NotificationCompat.BigTextStyle for your notification.
Like so:
NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle(); bigTextStyle.setBigContentTitle(getString(R.string.title)); bigTextStyle.bigText(getString(R.string.long_explanation)); mBuilder.setStyle(bigTextStyle);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With