0

I trying to add notification in my app. I tried the below code but the problem is that using the below code I can see only the partial text being displayed i.e I see only "Import the unzipped Android project" in the notification rest of the text is cut off.

NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(this)
                        .setSmallIcon(R.drawable.ic_launcher)
                        .setContentText("Import the unzipped Android project into Eclipse by selecting File")
                        .setContentTitle(getApplicationContext().getString(R.string.app_name))
                        .setContentIntent(notifyIntent);

enter image description here

So I tried BigTextStyle but now there is nothing displayed. Code below:

NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(this)
                        .setSmallIcon(R.drawable.ic_launcher)
                        .setContentTitle(getApplicationContext().getString(R.string.app_name))
                        .setContentIntent(notifyIntent);

        NotificationCompat.BigTextStyle textStyle = new NotificationCompat.BigTextStyle();
        textStyle.bigText("Import the unzipped Android project into Eclipse by selecting File");
        mBuilder.setStyle(textStyle);
        NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        mNotifyMgr.notify(mNotificationId, mBuilder.build());

Targeted API is 15 to 20 and the application is being tested on API 15.

Psypher
  • 10,717
  • 12
  • 59
  • 83

1 Answers1

0

Unfortunately, setBigText works on API 16 or higher, so the compat library forgo's doing this on 15 and lower

http://developer.android.com/reference/android/app/Notification.BigTextStyle.html#bigText(java.lang.CharSequence)

petey
  • 16,914
  • 6
  • 65
  • 97
  • So for API 16 and above i can use BigText, how about API 15, how can I show the complete text. – Psypher Sep 16 '14 at 20:37
  • Use an emulator set to api 16 or higher if you dont have a device handy. http://www.genymotion.com/ is pretty good as well as the provided emulator in the android sdk http://developer.android.com/tools/devices/emulator.html – petey Sep 16 '14 at 22:07
  • "But how can i make it work for api 15 devices?" you cant. setBigText works on API 16 or higher – petey Sep 17 '14 at 13:55
  • Not bigtext....i was referring to any other alternative to show complete text for api 15 devices – Psypher Sep 17 '14 at 13:58
  • Oh, take a look at this question and its answers (dont forget to upvote if you find them helpful). TL:DR, use a custom view and set a textview attribute of `android:ellipsize="marquee"` http://stackoverflow.com/q/7890882/794088 – petey Sep 17 '14 at 14:02