3

enter image description here

how to make this in two line like

ALERT

Pending follow-ups: 9

Enquery not attended once: 11

I am passing a string value "Pending follow-ups: " + all_follow_ups + "\n" + "Enquery not attended once: " + noOfEnquiry but not showing in two line.

I am using it android:minSdkVersion="7"

A J
  • 4,542
  • 5
  • 50
  • 80

2 Answers2

4

Add this in your code :

NotificationCompat.Builder builder = new NotificationCompat.Builder(
                context);
        Notification notification = builder.setContentIntent(contentIntent)
                .setSmallIcon(icon).setTicker(appname).setWhen(0)
                .setAutoCancel(true).setContentTitle(appname)
                .setStyle(new NotificationCompat.BigTextStyle().bigText(message))
                .setContentText(message).build();

        notificationManager.notify(0, notification);

Also Check this : Notification expand

Hope this helps.

Siddharth_Vyas
  • 9,972
  • 10
  • 39
  • 69
  • I am using it API level 7 – A J Nov 01 '13 at 06:43
  • Android 4.1 supports expandable notifications. In addition to normal notification view it is possible to define a big view which gets shown when notification is expanded. There are three styles to be used with the big view: big picture style, big text style, Inbox style. – Siddharth_Vyas Nov 01 '13 at 06:47
  • I don't think there is feature for api7. – Siddharth_Vyas Nov 01 '13 at 06:52
  • For API 16 (currently 95% of devices) you can use https://developer.android.com/reference/android/app/Notification.BigTextStyle.html instead of NotificationCompat. – pzulw May 09 '16 at 19:20
  • @Siddharth_Vyas what is the use of setTicker(appname) and setWhen(0) here?? – KJEjava48 Mar 10 '17 at 11:56
1

You could use RemoteViews for that.

In your custom_notification.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/custom_notification"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center" >

    <ImageView
        android:id="@+id/notifiation_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
     />

    <TextView 
         android:id="@+id/notification_title"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_toRightOf="@id/notification_image"
         android:layout_alignTop="@+id/notification_image"
     />

    <TextView
        android:id="@+id/notification_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/notification_image"
        android:layout_below="@+id/notification_title"
    />
    <TextView
        android:id="@+id/notification_text_second_line"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/notification_image"
        android:layout_below="@+id/notification_text"
    />

</RelativeLayout>

In notification building code:

RemoteViews contentView = new RemoteViews(getPackageName(),    R.layout.custom_notification);
contentView.setImageViewResource(R.id.notification_image,      R.drawable.notification_image);
contentView.setTextViewText(R.id.notification_title, "My custom    notification title");
contentView.setTextViewText(R.id.notification_text, "My custom notification text");
contentView.setTextViewText(R.id.notification_text_second_line, "My custom notification text second line");
NotificationCompat.Builder builder = new NotificationCompat.Builder(
            context);
Notification notification = builder
            .setAutoCancel(true)
            .setContent(contentView).build();
notificationManager.notify(0, notification);
satorikomeiji
  • 469
  • 6
  • 16