How to apply a big view style to a notification using Parse library
Here's an example using Notification.BigTextStyle
.
final String someLongText = "fkdljfdldkfj;ldaksjfkladj;flja;lkjdfljadslfjaddfdsfafjdfad" + "fdl;akjf;lkdf;lkaj;flkjda;lkfjadljflk;adsjfladjflk;dfjlkdjflakdfjdaffjdlfjdjjj" + "adjflkjadlkfjad;lkfjad;sljf;ladkjajlkfjad;lksfjl;akdjf;lkdsajf;lkdjfkadj;flkad" + "jf;lkadjfkldas;lkfja;dljf;lkdasjf;lkadjs;lfjas;ldkfj;lkadsjfl;kadljfl;kasdjf;l" + "jdlskfjklda;fjadslkfj;sdalkfj;ladjf;lajdl;fkajld;kfjlajfl;adjfl;kajdl;fjadl;kfj;"; final Notification.Builder builder = new Notification.Builder(this); builder.setStyle(new Notification.BigTextStyle(builder) .bigText(someLongText) .setBigContentTitle("Big title") .setSummaryText("Big summary")) .setContentTitle("Title") .setContentText("Summary") .setSmallIcon(android.R.drawable.sym_def_app_icon); final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(0, builder.build());
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());
This snippet shows how to construct the Builder object. It sets the style for the big view to be big text, and sets its content to be the reminder message.
String msg="This is Big style notification builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder."// Constructs the Builder object.NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_notification) .setContentTitle(getString(R.string.notification)) .setContentText(getString(R.string.ping)) .setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE permission .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);nm.notify(0, builder.build());
For more infomation go to:http://developer.android.com/training/notify-user/expanded.html