Java Code Examples for android.support.v7.app.NotificationCompat#BigPictureStyle

The following examples show how to use android.support.v7.app.NotificationCompat#BigPictureStyle . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotifyUtil0.java    From NotifyUtil with Apache License 2.0 6 votes vote down vote up
/**
 * 容纳大图片的通知
 *
 * @param pendingIntent
 * @param smallIcon
 * @param ticker
 * @param title
 * @param bigPic
 */
public void notify_bigPic(PendingIntent pendingIntent, int smallIcon, String ticker,
                          String title, String content, int bigPic, boolean sound, boolean vibrate, boolean lights) {

    setCompatBuilder(pendingIntent, smallIcon, ticker, title, null, sound, vibrate, lights);
    NotificationCompat.BigPictureStyle picStyle = new NotificationCompat.BigPictureStyle();
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inScaled = true;
    options.inSampleSize = 2;
    Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(),
            bigPic, options);
    picStyle.bigPicture(bitmap);
    picStyle.bigLargeIcon(bitmap);
    cBuilder.setContentText(content);
    cBuilder.setStyle(picStyle);
    sent();
}
 
Example 2
Source File: BigPicBuilder.java    From NotifyUtil with Apache License 2.0 6 votes vote down vote up
@Override
public void build() {
    super.build();
    NotificationCompat.BigPictureStyle picStyle = new NotificationCompat.BigPictureStyle();
    if(bitmap==null || bitmap.isRecycled()){
        if(bigPic >0){
            final BitmapFactory.Options options = new BitmapFactory.Options();
            options.inScaled = true;
            options.inSampleSize = 2;
            bitmap = BitmapFactory.decodeResource(NotifyUtil.context.getResources(),
                    bigPic, options);
        }
    }
    picStyle.bigPicture(bitmap);
    //picStyle.bigLargeIcon(bitmap);
    picStyle.setBigContentTitle(contentTitle);
    picStyle.setSummaryText(summaryText);
    cBuilder.setStyle(picStyle);
}
 
Example 3
Source File: NotifyUtil.java    From NotifyUtil with Apache License 2.0 6 votes vote down vote up
/**
 * 容纳大图片的通知
 *
 * @param pendingIntent
 * @param smallIcon
 * @param ticker
 * @param title
 * @param bigPic
 */
public void notify_bigPic(PendingIntent pendingIntent, int smallIcon, String ticker,
                          String title, String content, int bigPic, boolean sound, boolean vibrate, boolean lights) {

    setCompatBuilder(pendingIntent, smallIcon, ticker, title, null, sound, vibrate, lights);
    NotificationCompat.BigPictureStyle picStyle = new NotificationCompat.BigPictureStyle();
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inScaled = true;
    options.inSampleSize = 2;
    Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(),
            bigPic, options);
    picStyle.bigPicture(bitmap);
    picStyle.bigLargeIcon(bitmap);
    cBuilder.setContentText(content);
    cBuilder.setStyle(picStyle);
    sent();
}
 
Example 4
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
public void sendBig(View view) {
    //1.创建Builder
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setSmallIcon(R.mipmap.hmv).setTicker("大图标通知");
    //2.创建BigPictureStyle
    NotificationCompat.BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle(builder);
    //3.设置BigPictureStyle
    //标题
    bigPictureStyle.setSummaryText("大图标内容文本")
            .setBigContentTitle("大图标标题");
    //设置大图片,bitmap对象
    //把R.drawable.id-->Bitmap
    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.big);
    bigPictureStyle.bigPicture(bitmap);
    //4.发送
    Notification notification = builder.build();

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(103, notification);


}