Search in sources :

Example 16 with TaskStackBuilder

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

the class NotifyService method setInboxStyleNotification.

/**
	 * Inbox Style Notification
	 * 
	 * @return Notification
	 * @see CreateNotification
	 */
private Notification setInboxStyleNotification(String content) {
    Bitmap remote_picture = null;
    // Create the style object with InboxStyle subclass.
    NotificationCompat.InboxStyle notiStyle = new NotificationCompat.InboxStyle();
    notiStyle.setBigContentTitle("Inbox Style Expanded");
    // This is strictly for providing an example of multiple lines.
    for (int i = 0; i < 5; i++) {
        notiStyle.addLine("(" + i + " of 6) Line one here.");
    }
    notiStyle.setSummaryText("+2 more Line Samples");
    try {
        remote_picture = BitmapFactory.decodeStream((InputStream) new URL(sample_url).getContent());
    } catch (IOException e) {
        e.printStackTrace();
    }
    // 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("Inbox Style 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)

Example 17 with TaskStackBuilder

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

the class NotifyService method setBigTextStyleNotification.

/**
	 * Big Text Style Notification
	 * 
	 * @return Notification
	 * @see CreateNotification
	 */
private Notification setBigTextStyleNotification(String content) {
    Bitmap remote_picture = null;
    // Create the style object with BigTextStyle subclass.
    NotificationCompat.BigTextStyle notiStyle = new NotificationCompat.BigTextStyle();
    notiStyle.setBigContentTitle("Big Text Expanded");
    notiStyle.setSummaryText("Nice big text.");
    try {
        remote_picture = BitmapFactory.decodeStream((InputStream) new URL(sample_url).getContent());
    } catch (IOException e) {
        e.printStackTrace();
    }
    // Add the big text to the style.
    CharSequence bigText = "This is an example of a large string to demo how much " + "text you can show in a 'Big Text Style' notification.";
    notiStyle.bigText(bigText);
    // 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 Text 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)

Example 18 with TaskStackBuilder

use of android.support.v4.app.TaskStackBuilder 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)

Example 19 with TaskStackBuilder

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

the class NotifyService method setBigTextStyleNotification.

/**
	 * Big Text Style Notification
	 * 
	 * @return Notification
	 * @see CreateNotification
	 */
private Notification setBigTextStyleNotification(String content) {
    Bitmap remote_picture = null;
    // Create the style object with BigTextStyle subclass.
    NotificationCompat.BigTextStyle notiStyle = new NotificationCompat.BigTextStyle();
    notiStyle.setBigContentTitle("Big Text Expanded");
    notiStyle.setSummaryText("Nice big text.");
    try {
        remote_picture = BitmapFactory.decodeStream((InputStream) new URL(sample_url).getContent());
    } catch (IOException e) {
        e.printStackTrace();
    }
    // Add the big text to the style.
    CharSequence bigText = "This is an example of a large string to demo how much " + "text you can show in a 'Big Text Style' notification.";
    notiStyle.bigText(bigText);
    // 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 Text 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)

Example 20 with TaskStackBuilder

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

the class NotifyService method setInboxStyleNotification.

/**
	 * Inbox Style Notification
	 * 
	 * @return Notification
	 * @see CreateNotification
	 */
private Notification setInboxStyleNotification(String content) {
    Bitmap remote_picture = null;
    // Create the style object with InboxStyle subclass.
    NotificationCompat.InboxStyle notiStyle = new NotificationCompat.InboxStyle();
    notiStyle.setBigContentTitle("Inbox Style Expanded");
    // This is strictly for providing an example of multiple lines.
    for (int i = 0; i < 5; i++) {
        notiStyle.addLine("(" + i + " of 6) Line one here.");
    }
    notiStyle.setSummaryText("+2 more Line Samples");
    try {
        remote_picture = BitmapFactory.decodeStream((InputStream) new URL(sample_url).getContent());
    } catch (IOException e) {
        e.printStackTrace();
    }
    // 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("Inbox Style 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

Intent (android.content.Intent)39 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)38 PendingIntent (android.app.PendingIntent)34 NotificationCompat (android.support.v4.app.NotificationCompat)20 NotificationManager (android.app.NotificationManager)14 Bitmap (android.graphics.Bitmap)13 InputStream (java.io.InputStream)10 IOException (java.io.IOException)8 URL (java.net.URL)8 Notification (android.app.Notification)7 Context (android.content.Context)5 Uri (android.net.Uri)5 SharedPreferences (android.content.SharedPreferences)3 Resources (android.content.res.Resources)3 Cursor (android.database.Cursor)3 RemoteViews (android.widget.RemoteViews)3 TaskStackBuilder (android.app.TaskStackBuilder)2 ContentResolver (android.content.ContentResolver)2 Bundle (android.os.Bundle)2 NonNull (android.support.annotation.NonNull)2