How to apply a big view style to a notification using Parse library

前端 未结 8 867
孤街浪徒
孤街浪徒 2021-02-04 06:03

This library works perfectly, but i have a doubt.

When I send a message to users with more than two lines, users can\'t see all message in notification area.

But

8条回答
  •  离开以前
    2021-02-04 06:43

    Bitmap icon1 = BitmapFactory.decodeResource(getResources(),
                        R.drawable.gorio);
    
                NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                        getApplicationContext()).setAutoCancel(true)
                        .setContentTitle("Exemplo 1")
                        .setSmallIcon(R.drawable.gorio)
                        .setLargeIcon(icon1).setContentText("Hello World!");
    
                NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle();
                bigText.bigText(msg);
                bigText.setBigContentTitle("GORIO Engenharia");
                bigText.setSummaryText("Por: GORIO Engenharia");
                mBuilder.setStyle(bigText);
                mBuilder.setPriority(NotificationCompat.PRIORITY_MAX);
    
                // Creates an explicit intent for an Activity in your app
                Intent resultIntent = new Intent(getApplicationContext(),
                        MainActivity.class);
    
                // The stack builder object will contain an artificial back
                // stack for
                // the
                // started Activity.
                // getApplicationContext() ensures that navigating backward from
                // the Activity leads out of
                // your application to the Home screen.
                TaskStackBuilder stackBuilder = TaskStackBuilder
                        .create(getApplicationContext());
    
                // Adds the back stack for the Intent (but not the Intent
                // itself)
                stackBuilder.addParentStack(MainActivity.class);
    
                // Adds the Intent that starts the Activity to the top of the
                // stack
                stackBuilder.addNextIntent(resultIntent);
                PendingIntent resultPendingIntent = stackBuilder
                        .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
                mBuilder.setContentIntent(resultPendingIntent);
    
                NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    
                // mId allows you to update the notification later on.
                mNotificationManager.notify(100, mBuilder.build());
    

提交回复
热议问题