本文整理匯總了Java中android.support.v7.app.NotificationCompat.InboxStyle方法的典型用法代碼示例。如果您正苦於以下問題:Java NotificationCompat.InboxStyle方法的具體用法?Java NotificationCompat.InboxStyle怎麽用?Java NotificationCompat.InboxStyle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.app.NotificationCompat
的用法示例。
在下文中一共展示了NotificationCompat.InboxStyle方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showSmallNotification
import android.support.v7.app.NotificationCompat; //導入方法依賴的package包/類
private void showSmallNotification(NotificationCompat.Builder mBuilder, int icon, String title, String message, String timeStamp, PendingIntent resultPendingIntent, Uri alarmSound) {
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.addLine(message);
Notification notification;
notification = mBuilder.setSmallIcon(icon).setTicker(title).setWhen(0)
.setAutoCancel(true)
.setContentTitle(title)
.setContentIntent(resultPendingIntent)
.setSound(alarmSound)
.setStyle(inboxStyle)
.setWhen(getTimeMilliSec(timeStamp))
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
.setContentText(message)
.build();
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(Config.NOTIFICATION_ID, notification);
}
示例2: build
import android.support.v7.app.NotificationCompat; //導入方法依賴的package包/類
@Override
public void build() {
super.build();
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
for (String msg : messageList) {
inboxStyle.addLine(msg);
}
String text = "[" + messageList.size() + "]條信息";
inboxStyle.setSummaryText(text);
cBuilder.setStyle(inboxStyle);
cBuilder.setContentText("你有"+text);
if(TextUtils.isEmpty(ticker)){
cBuilder.setTicker(text);
}
}
示例3: notify_mailbox
import android.support.v7.app.NotificationCompat; //導入方法依賴的package包/類
/**
* 進行多項設置的通知(在小米上似乎不能設置大圖標,係統默認大圖標為應用圖標)
*
* @param pendingIntent
* @param smallIcon
* @param ticker
* @param title
* @param content
*/
public void notify_mailbox(PendingIntent pendingIntent, int smallIcon, int largeIcon, ArrayList<String> messageList,
String ticker, String title, String content, boolean sound, boolean vibrate, boolean lights) {
setCompatBuilder(pendingIntent, smallIcon, ticker, title, content, sound, vibrate, lights);
// 將Ongoing設為true 那麽notification將不能滑動刪除
//cBuilder.setOngoing(true);
/**
// 刪除時
Intent deleteIntent = new Intent(mContext, DeleteService.class);
int deleteCode = (int) SystemClock.uptimeMillis();
// 刪除時開啟一個服務
PendingIntent deletePendingIntent = PendingIntent.getService(mContext,
deleteCode, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT);
cBuilder.setDeleteIntent(deletePendingIntent);
**/
Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), largeIcon);
cBuilder.setLargeIcon(bitmap);
cBuilder.setDefaults(Notification.DEFAULT_ALL);// 設置使用默認的聲音
//cBuilder.setVibrate(new long[]{0, 100, 200, 300});// 設置自定義的振動
cBuilder.setAutoCancel(true);
// builder.setSound(Uri.parse("file:///sdcard/click.mp3"));
// 設置通知樣式為收件箱樣式,在通知中心中兩指往外拉動,就能出線更多內容,但是很少見
//cBuilder.setNumber(messageList.size());
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
for (String msg : messageList) {
inboxStyle.addLine(msg);
}
inboxStyle.setSummaryText("[" + messageList.size() + "條]" + title);
cBuilder.setStyle(inboxStyle);
sent();
}