Search in sources :

Example 6 with BigPictureStyle

use of android.support.v4.app.NotificationCompat.BigPictureStyle in project AprilBeacon-Android-SDK by AprilBrother.

the class NotifyService method setBigPictureStyleNotification.

/**
 * Big Picture Style Notification
 *
 * @return Notification
 * @see CreateNotification
 */
private Notification setBigPictureStyleNotification(String content) {
    Bitmap remote_picture = null;
    // Create the style object with BigPictureStyle subclass.
    NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle();
    notiStyle.setBigContentTitle("Big Picture Expanded");
    notiStyle.setSummaryText("Nice big picture.");
    try {
        remote_picture = BitmapFactory.decodeStream((InputStream) new URL(sample_url).getContent());
    } catch (IOException e) {
        e.printStackTrace();
    }
    // Add the big picture to the style.
    notiStyle.bigPicture(remote_picture);
    // Creates an explicit intent for an ResultActivity to receive.
    Intent resultIntent = new Intent(this, ResultActivity.class);
    // This ensures that the back button follows the recommended convention
    // for the back key.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    // Adds the back stack for the Intent (but not the Intent itself).
    stackBuilder.addParentStack(ResultActivity.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);
    return new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true).setLargeIcon(remote_picture).setContentIntent(resultPendingIntent).addAction(R.drawable.ic_launcher, "One", resultPendingIntent).addAction(R.drawable.ic_launcher, "Two", resultPendingIntent).addAction(R.drawable.ic_launcher, "Three", resultPendingIntent).setContentTitle("Big Picture Normal").setContentText(content).setStyle(notiStyle).build();
}
Also used : Bitmap(android.graphics.Bitmap) InputStream(java.io.InputStream) NotificationCompat(android.support.v4.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) IOException(java.io.IOException) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.support.v4.app.TaskStackBuilder) URL(java.net.URL)

Aggregations

NotificationCompat (android.support.v4.app.NotificationCompat)5 Notification (android.app.Notification)3 PendingIntent (android.app.PendingIntent)3 Intent (android.content.Intent)3 Bitmap (android.graphics.Bitmap)3 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 URL (java.net.URL)2 BigPictureStyle (android.support.v4.app.NotificationCompat.BigPictureStyle)1 RemoteViews (android.widget.RemoteViews)1 Message (de.pixart.messenger.entities.Message)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1