Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is possible set Expanded Notification as default in Big Text Notifications?

I followed this Sample Code

In Big Text Notifications section, he said that need expand to see Big text notification form, as image im below :

enter image description here

I wonder that we can not set Expanded Notification as default in Big Text Notifications?

People who know it is can or not,

If can,

Please tell me how to do it,

Thanks,

like image 788
Huy Tower Avatar asked Apr 28 '14 02:04

Huy Tower


People also ask

How do you make an expandable notification?

An expandable Notification is a special case of a Notification Big View . If the Big View is not at the top of the notification drawer, it it shown 'closed' and is expandable by swipe.

How do I get full text notifications on Android?

1 I can just "pull down" the notification (using one finger) or pinch-zoom it (using two fingers) to see the full text: first, pull down the notification bar. then pull down the single notification, where the text is cropped.

How do I expand notifications on Android?

To expand a notification, tap the Down arrow . Then, to act directly from a notification, tap an action, like Reply or Archive. Some apps show a dot when you get a notification. Touch and hold the app with the dot to see the oldest notification.

How many types of notifications are there in Android?

Following are the three types of android notifications, Toast Notification – Shows message that fades away after a few seconds. (Background type also) Status Notification – Shows notification message and displayed till user action.


3 Answers

The documentation states:

A notification's big view appears only when the notification is expanded, which happens when the notification is at the top of the notification drawer, or when the user expands the notification with a gesture.

So my answer is no, you can't expand it by default.

There is however a trick to push the notification to the top of the list where it would be expanded. Simply set the Priority to Notification.PRIORITY_MAX and chances are that your app's notification will make it to the top.

like image 118
Emanuel Moecklin Avatar answered Oct 02 '22 16:10

Emanuel Moecklin


Notification noti = new Notification.Builder()
... // The same notification properties as the others
.setStyle(new Notification.BigPictureStyle().bigPicture(mBitmap))
.build();

You change

.setStyle(new NotificationCompat.BigTextStyle().bigText(th_alert))

along with the announcement

notification = new NotificationCompat.Builder(context)

Here is an example:

enter image description hereYou can set Code

Intent intent = new Intent(context, ReserveStatusActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
NotificationManager notificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
intent = new Intent(String.valueOf(PushActivity.class));
intent.putExtra("message", MESSAGE);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(PushActivity.class);
stackBuilder.addNextIntent(intent);
// PendingIntent pendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

// android.support.v4.app.NotificationCompat.BigTextStyle bigStyle = new     NotificationCompat.BigTextStyle();
// bigStyle.bigText((CharSequence) context);

notification = new NotificationCompat.Builder(context)
    .setSmallIcon(R.mipmap.ic_launcher)
    .setContentTitle(th_title)
    .setContentText(th_alert)
    .setAutoCancel(true)
 // .setStyle(new Notification.BigTextStyle().bigText(th_alert)  ตัวเก่า
 // .setStyle(new NotificationCompat.BigTextStyle().bigText(th_title))
    .setStyle(new NotificationCompat.BigTextStyle().bigText(th_alert))
    .setContentIntent(pendingIntent)
    .setNumber(++numMessages)
    .build();

notification.sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notificationManager.notify(1000, notification);
like image 38
Pong Petrung Avatar answered Oct 02 '22 16:10

Pong Petrung


notificationBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText("Your Long Text here"))

simply setStyle of your notification builder.

like image 20
Abdurahman Popal Avatar answered Sep 29 '22 16:09

Abdurahman Popal