0

Hi guys i want try to show notification in android 2.3.x but doesn't work. In Android 4.x this work fine... there is a logcat:

http://paste.ubuntu.com/7648767/

code:

protected void ShowNotification(int icon ,String title, String text){
    NotificationCompat.Builder mBuilder =
        new NotificationCompat.Builder(getBaseContext())
        .setSmallIcon(icon)
        .setContentTitle(title)
        .setContentText(text)
        .setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE permission
        .setStyle(new NotificationCompat.BigTextStyle()
        .bigText(text));

    NotificationManager notificationManager = 
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(incMyNum(), mBuilder.build());
    Uri alarmSound = RingtoneManager
        .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    mBuilder.setSound(alarmSound);
    mBuilder.build();
}

in logcat:

06-15 16:20:53.989: E/AndroidRuntime(451):  at com...........ShowNotification(DettagliVolo.java:639)

is this:

notificationManager.notify(incMyNum(), mBuilder.build());

AndroidManifest:

<uses-permission android:name="android.permission.VIBRATE" />

In emulator with GB crash... and if i run my application in a emulator with ICS+ work fine! There is a solution? Thank you!

2.Question: is possible show notification default in big mode? (expanded)

isaias-b
  • 2,255
  • 2
  • 25
  • 38
user3671540
  • 135
  • 3
  • 11

1 Answers1

1

Supplying a PendingIntent as content Intent (to be executed when the notification is clicked) is mandatory for some Android versions.

Provide one (at least opening your app's main Activity) with mBuilder.setContentintent().

matiash
  • 54,791
  • 16
  • 125
  • 154