Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Big View Notification Android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 185
    Comment on it

    This tutorial is about Big View of Notification.

    Big View notification introduced in Android 4.1.

    Big View Notification has advantage to set functionality from Notification like you  Alarm application
    and you can Dismiss/Snooze alarm from notification with Big View Notification.

     

    Here we Start.

    1. Create Pending Intent for Notification when user click on Notification.

     Intent intent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://google.com"));
            PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);

     

    2. Create Intents for Big View.

     Intent facebook = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://fb.com"));
            
            PendingIntent piFb =  PendingIntent.getActivity(this, 0, facebook, 0);
    
            
            Intent google = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://google.com"));
    
            PendingIntent piGoogle =  PendingIntent.getActivity(this, 0, google, 0);

     

    3. Create Notification Builder object.

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);

     

    4. Set Notification icon.

    builder.setSmallIcon(R.drawable.ic_stat_notification);

     

    5. Set Pending Content.

     builder.setContentIntent(pendingIntent);

     

    6. Set Auto Cancel.

    builder.setAutoCancel(true);

     

    7. Set Text to Notification.

      builder.setContentTitle("Big View Notification");
            builder.setContentText("This is content text of Big View Notification");
            builder.setSubText("sub text of notification");

     

    8. Set Notification Type to BigView Type.

     builder.setStyle(new NotificationCompat.BigTextStyle()
                    .bigText("Big View Message"))
                    .addAction (R.drawable.ic_launcher,
                            "Facebook ", piFb)
                    .addAction (R.drawable.ic_launcher,
                            "Google", piGoogle);

     

    9. Create Notification Manager.

      NotificationManager notificationManager = (NotificationManager) getSystemService(
                    NOTIFICATION_SERVICE);

     

    10. call below line of code from you button click to Notify Notification .

     notificationManager.notify(NOTIFICATION_ID, builder.build());

     

    Happy Coding :D

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
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: