Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Big View Notification - How to Apply Expanded Layout to Android Notification

    • 0
    • 0
    • 0
    • 0
    • 2
    • 0
    • 2
    • 0
    • 1.15k
    Comment on it

    There are two types of visual style which appear on the Notification, normal view and big view.

    So, here in this tutorial, we will see how to Apply Expanded Layout to Android Notification. Regarding Nig View Notification, you should aware that the Notification big view appears only when top of the notification drawer is expended by the user.


    Here below is an Example of small view Notification.




    Here below is an Example of Big view Notification.





    Here is the way to apply Expended layout to the Notification

    First, create the Object with normal view using NotificationCompat.Builder and  the big style object using NotificationCompat.BigTextStyle and after then call the Builder.setStyle() with expanded layout object as its argument.


           String bigText ="Android is a Linux-based operating system designed primarily for touchscreen mobile devices such as smartphones and tablet computers. Initially developed by Android, Inc., which Google backed financially and later bought in 2005,[12] Android was unveiled in 2007 along with the founding of the Open Handset Alliance:";
            Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
            // Creates an explicit intent for an ResultActivity to receive.
            Intent intent = new Intent(this, MainActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.appicon_postallhere, 0)
                    .setContentTitle("new messages normal view")
            // Create the style object with BigTextStyle subclass.
            NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle()
                    .setBigContentTitle("new messages big view")
            // This ensures that the back button follows the recommended
            // convention for the back key
            TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(this);
            // Adds the back stack for the Intent (but not the Intent itself).
            // Adds the Intent that starts the Activity to the top of the stack.
            NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this);


    Big View Notification - How to Apply Expanded Layout to Android Notification

 2 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: