通知android创建时没有通知标题动画

时间:2014-03-08 02:06:45

标签: android notifications

我试过通知果冻豆。当通知到来或创建时,只有状态栏中显示的第一个图标,没有通知标题动画......

查看此图片,创建此显示图标和标题,但我的通知只是图标。

enter image description here

这是我的代码

 private static void generateNotification(Context context,String kat_pesan, String title, String message ,String judul,String  komentar,String  sekilas_isi,String 
             date,String gambar_tulisan_detail,String id_tulisan,String status_gambar, 
             String kategori, String main_kategori,String seo_detail,String pengomentar, String isi_komentar, String kordinat_lokasi, String username, String avatar) {
         long when = System.currentTimeMillis();
        Random rand = new Random(System.currentTimeMillis());
        int unique_ids=rand.nextInt();

        NotificationManager notificationManager = (NotificationManager)
                context.getSystemService(Context.NOTIFICATION_SERVICE);


            Notification notification = null;
             notification = setBigTextStyleNotification(context,kat_pesan,title, message, judul,komentar, sekilas_isi,
                             date,gambar_tulisan_detail,id_tulisan,status_gambar,kategori,main_kategori,
                             seo_detail,pengomentar,isi_komentar, kordinat_lokasi, username,avatar,
                            when,unique_ids); 


            notification.flags |= Notification.FLAG_AUTO_CANCEL;

            // Play default notification sound
            notification.defaults |= Notification.DEFAULT_SOUND;

            //notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3");

            // Vibrate if vibrate is enabled
            notification.defaults |= Notification.DEFAULT_VIBRATE;
            notification.number += 1;

            notificationManager.notify(unique_ids, notification);  

    }

private static Notification setBigTextStyleNotification(Context context, String kat_pesan, String title, String message, String judul, 
            String komentar, String sekilas_isi, String date, String gambar_tulisan_detail, String id_tulisan, String status_gambar, 
            String kategori, String main_kategori, String seo_detail, String pengomentar, String isi_komentar, String kordinat_lokasi, 
            String username, String avatar, long when, int unique_ids) {
        Bitmap remote_picture = null;

        NotificationCompat.BigTextStyle notiStyle = new NotificationCompat.BigTextStyle();
        notiStyle.setBigContentTitle(judul);

        remote_picture = getBitmapFromURL(gambar_tulisan_detail);

        notiStyle.bigText(sekilas_isi);
        Intent resultIntent = new Intent(context, DetailIsi.class); 
        resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);

        stackBuilder.addParentStack(DetailIsi.class);

        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(unique_ids, PendingIntent.FLAG_UPDATE_CURRENT);

        return new NotificationCompat.Builder(context)
               .setSmallIcon(R.drawable.icon_notification)
                .setAutoCancel(true)
                .setLargeIcon(remote_picture)
                .setContentIntent(resultPendingIntent)
              .addAction(0, "Open Detail", resultPendingIntent)
                .setContentTitle("#"+main_kategori+" #"+kategori)
                .setContentText(judul)
                .setStyle(notiStyle).build();
    }

如何解决?谢谢,对不起我的英文

1 个答案:

答案 0 :(得分:1)

您需要设置代码:

NotificationCompat.Builder.setTicker(CharSequence tickerText)

试试这个:

return new NotificationCompat.Builder(context)
    .setSmallIcon(R.drawable.icon_notification)
    .setAutoCancel(true)
    .setLargeIcon(remote_picture)
    .setContentIntent(resultPendingIntent)
    .addAction(0, "Open Detail", resultPendingIntent)
    .setContentTitle("#"+main_kategori+" #"+kategori)
    .setContentText(judul)
    .setTicker(judul)
    .setStyle(notiStyle).build();