本文整理匯總了Java中android.support.v4.app.NotificationCompat.BigTextStyle方法的典型用法代碼示例。如果您正苦於以下問題:Java NotificationCompat.BigTextStyle方法的具體用法?Java NotificationCompat.BigTextStyle怎麽用?Java NotificationCompat.BigTextStyle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.app.NotificationCompat
的用法示例。
在下文中一共展示了NotificationCompat.BigTextStyle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createBigTextStyleNotification
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
protected NotificationCompat.Builder createBigTextStyleNotification(Account account, NotificationHolder holder,
int notificationId) {
String accountName = controller.getAccountName(account);
NotificationContent content = holder.content;
String groupKey = NotificationGroupKeys.getGroupKey(account);
NotificationCompat.Builder builder = createAndInitializeNotificationBuilder(account)
.setTicker(content.summary)
.setGroup(groupKey)
.setContentTitle(content.sender)
.setContentText(content.subject)
.setSubText(accountName);
NotificationCompat.BigTextStyle style = createBigTextStyle(builder);
style.bigText(content.preview);
builder.setStyle(style);
PendingIntent contentIntent = actionCreator.createViewMessagePendingIntent(
content.messageReference, notificationId);
builder.setContentIntent(contentIntent);
return builder;
}
示例2: showDisabledNotification
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
private void showDisabledNotification() {
Intent main = new Intent(this, ActivityMain.class);
PendingIntent pi = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT);
TypedValue tv = new TypedValue();
getTheme().resolveAttribute(R.attr.colorOff, tv, true);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_error_white_24dp)
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.msg_revoked))
.setContentIntent(pi)
.setColor(tv.data)
.setOngoing(false)
.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setCategory(Notification.CATEGORY_STATUS)
.setVisibility(Notification.VISIBILITY_SECRET);
}
NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder);
notification.bigText(getString(R.string.msg_revoked));
NotificationManagerCompat.from(this).notify(NOTIFY_DISABLED, notification.build());
}
示例3: showAutoStartNotification
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
private void showAutoStartNotification() {
Intent main = new Intent(this, ActivityMain.class);
main.putExtra(ActivityMain.EXTRA_APPROVE, true);
PendingIntent pi = PendingIntent.getActivity(this, NOTIFY_AUTOSTART, main, PendingIntent.FLAG_UPDATE_CURRENT);
TypedValue tv = new TypedValue();
getTheme().resolveAttribute(R.attr.colorOff, tv, true);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_error_white_24dp)
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.msg_autostart))
.setContentIntent(pi)
.setColor(tv.data)
.setOngoing(false)
.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setCategory(Notification.CATEGORY_STATUS)
.setVisibility(Notification.VISIBILITY_SECRET);
}
NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder);
notification.bigText(getString(R.string.msg_autostart));
NotificationManagerCompat.from(this).notify(NOTIFY_AUTOSTART, notification.build());
}
示例4: showErrorNotification
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
private void showErrorNotification(String message) {
Intent main = new Intent(this, ActivityMain.class);
PendingIntent pi = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT);
TypedValue tv = new TypedValue();
getTheme().resolveAttribute(R.attr.colorOff, tv, true);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_error_white_24dp)
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.msg_error, message))
.setContentIntent(pi)
.setColor(tv.data)
.setOngoing(false)
.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setCategory(Notification.CATEGORY_STATUS)
.setVisibility(Notification.VISIBILITY_SECRET);
}
NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder);
notification.bigText(getString(R.string.msg_error, message));
notification.setSummaryText(message);
NotificationManagerCompat.from(this).notify(NOTIFY_ERROR, notification.build());
}
示例5: showUpdateNotification
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
private void showUpdateNotification(String name, String url) {
Intent download = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
PendingIntent pi = PendingIntent.getActivity(this, 0, download, PendingIntent.FLAG_UPDATE_CURRENT);
TypedValue tv = new TypedValue();
getTheme().resolveAttribute(R.attr.colorPrimary, tv, true);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_security_white_24dp)
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.msg_update))
.setContentIntent(pi)
.setColor(tv.data)
.setOngoing(false)
.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setCategory(Notification.CATEGORY_STATUS)
.setVisibility(Notification.VISIBILITY_SECRET);
}
NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder);
notification.bigText(getString(R.string.msg_update));
notification.setSummaryText(name);
NotificationManagerCompat.from(this).notify(NOTIFY_UPDATE, notification.build());
}
示例6: setNotificationText
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
private void setNotificationText(NotificationCompat.Builder builder)
{
final Resources res = getResources();
final long now = SystemClock.elapsedRealtime();
final long lastTestDelta = loopModeResults.getLastTestTime() == 0 ? 0 : now - loopModeResults.getLastTestTime();
final String elapsedTimeString = LoopModeTriggerItem.formatSeconds(Math.round(lastTestDelta / 1000), 1);
final CharSequence textTemplate = res.getText(R.string.loop_notification_text_without_stop);
final CharSequence text = MessageFormat.format(textTemplate.toString(),
loopModeResults.getNumberOfTests(), elapsedTimeString, Math.round(loopModeResults.getLastDistance()));
builder.setContentText(text);
if (bigTextStyle == null)
{
bigTextStyle = (new NotificationCompat.BigTextStyle());
builder.setStyle(bigTextStyle);
}
bigTextStyle.bigText(text);
}
示例7: makeBigTextStyle
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
public static NotificationCompat.BigTextStyle makeBigTextStyle(CharSequence title,
CharSequence text) {
NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle()
.setBigContentTitle(title);
bigTextStyle.bigText(text);
return bigTextStyle;
}
示例8: sendNotification
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
private void sendNotification(String messageTitle, String messageBody) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT);
if (messageTitle == null) messageTitle = "";
if (messageBody == null) messageBody = "";
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setLights(Color.WHITE, 1000, 1000)
.setContentTitle(messageTitle.isEmpty() ? getString(R.string.app_name) : messageTitle)
.setContentText(messageBody)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
.setSmallIcon(R.drawable.ic_fcm_notification)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
notificationBuilder.setPriority(Notification.PRIORITY_DEFAULT);
NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
bigTextStyle.setBigContentTitle(messageTitle.isEmpty() ? getString(R.string.app_name) : messageTitle);
bigTextStyle.bigText(messageBody);
notificationBuilder.setStyle(bigTextStyle);
}
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notificationToShow = notificationBuilder.build();
notificationToShow.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(notificationCount++, notificationToShow);
}
示例9: alert
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
private void alert(Crate crate, Crate oldCrate, AlertType type) {
String title = type.getName(crate);
String description = type.getDescription(crate, oldCrate);
NotificationCompat.BigTextStyle notiStyle = new
NotificationCompat.BigTextStyle();
notiStyle.bigText(description);
Notification notification = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(title)
.setContentText(description).setVibrate(new long[] { 1000, 1000, 1000})
.setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
.setAutoCancel(true)
.setStyle(notiStyle)
.build();
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(maxNotificationId, notification);
if (maxNotificationId + 1 == Integer.MAX_VALUE) {
maxNotificationId = 0;
}
maxNotificationId++;
}
示例10: setTitleAndText
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
private void setTitleAndText(String title, String body, boolean isPost) {
builder.setContentTitle(title);
builder.setContentText(body);
builder.setTicker(body);
if (isPost) {
builder.setSmallIcon(R.drawable.ic_post);
NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle(builder);
bigTextStyle.setBigContentTitle(title);
bigTextStyle.setSummaryText(body);
builder.setStyle(bigTextStyle);
} else {
builder.setSmallIcon(R.drawable.ic_comment);
}
}
示例11: build
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
@Override
public void build() {
super.build();
NotificationCompat.BigTextStyle textStyle = new NotificationCompat.BigTextStyle();
textStyle.setBigContentTitle(contentTitle).bigText(contentText).setSummaryText(summaryText);
cBuilder.setStyle(textStyle);
}
示例12: buildNotification
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
/**
* Builds a {@link NotificationCompat.Builder} with some predefined properties
*
* @param title notification title
* @param text notification body, can be null
* @param hasUndefinedProgress declare if the notification have to contain an undefined progressbar
* @return a {@link NotificationCompat.Builder} with the properties passed as parameter.
*/
private NotificationCompat.Builder buildNotification(String title, String text, Boolean hasUndefinedProgress) {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
mBuilder.setContentTitle(title);
NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle();
if (text != null) {
style.bigText(text);
}
mBuilder.setStyle(style);
mBuilder.setSmallIcon(R.drawable.ic_reply_white_24dp);
if (hasUndefinedProgress) {
mBuilder.setProgress(0, 0, true);
}
return mBuilder;
}
示例13: createInstalledSummaryNotification
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
private Notification createInstalledSummaryNotification(ArrayList<AppUpdateStatusManager.AppUpdateStatus> installed) {
String title = context.getResources().getQuantityString(R.plurals.notification_summary_installed,
installed.size(), installed.size());
StringBuilder text = new StringBuilder();
NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
bigTextStyle.setBigContentTitle(title);
for (int i = 0; i < MAX_INSTALLED_TO_SHOW && i < installed.size(); i++) {
AppUpdateStatusManager.AppUpdateStatus entry = installed.get(i);
App app = entry.app;
if (text.length() > 0) {
text.append(", ");
}
text.append(app.name);
}
bigTextStyle.bigText(text);
if (installed.size() > MAX_INSTALLED_TO_SHOW) {
int diff = installed.size() - MAX_INSTALLED_TO_SHOW;
bigTextStyle.setSummaryText(context.getResources().getQuantityString(R.plurals.notification_summary_more,
diff, diff));
}
// Intent to open main app list
Intent intentObject = new Intent(context, MainActivity.class);
PendingIntent piAction = PendingIntent.getActivity(context, 0, intentObject, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder =
new NotificationCompat.Builder(context)
.setAutoCancel(!useStackedNotifications())
.setSmallIcon(R.drawable.ic_notification)
.setColor(ContextCompat.getColor(context, R.color.fdroid_blue))
.setContentTitle(title)
.setContentText(text)
.setContentIntent(piAction)
.setLocalOnly(true)
.setVisibility(NotificationCompat.VISIBILITY_SECRET);
if (useStackedNotifications()) {
builder.setGroup(GROUP_INSTALLED)
.setGroupSummary(true);
}
Intent intentDeleted = new Intent(BROADCAST_NOTIFICATIONS_ALL_INSTALLED_CLEARED);
intentDeleted.setClass(context, NotificationBroadcastReceiver.class);
PendingIntent piDeleted = PendingIntent.getBroadcast(context, 0, intentDeleted, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setDeleteIntent(piDeleted);
return builder.build();
}
示例14: BigText
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
public BigText() {
style = new NotificationCompat.BigTextStyle();
}
示例15: notify
import android.support.v4.app.NotificationCompat; //導入方法依賴的package包/類
private void notify(ContentValues cv, PendingIntent pi, Uri sound, boolean isHeadUp) {
String body = FeedContract.removeHtml(cv.getAsString(FeedContract.Feeds.COLUMN_Body));
String title= FeedContract.removeHtml(cv.getAsString(FeedContract.Feeds.COLUMN_Title));
String link = cv.getAsString(FeedContract.Feeds.COLUMN_Link);
Bitmap largeIcon = FeedContract.getImage(cv.getAsByteArray(FeedContract.Feeds.COLUMN_Image));
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(_ctx);
NotificationCompat.BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
bigStyle.bigText(body);
if (largeIcon == null)
largeIcon = BitmapFactory.decodeResource(_ctx.getResources(), R.mipmap.ic_launcher);
mBuilder.setContentTitle(title)
.setContentText(body)
.setTicker(body)
.setContentIntent(pi)
.setStyle(bigStyle)
.setSmallIcon(R.drawable.logo_sw)
.setLargeIcon(largeIcon);
if (! isHeadUp) {
Intent linkIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
PendingIntent linkpi = PendingIntent.getActivity(
AnotherRSS.getContextOfApplication(), 0, linkIntent, 0
);
mBuilder.addAction(
android.R.drawable.ic_menu_view,
AnotherRSS.getContextOfApplication().getString(R.string.open),
linkpi
);
} else {
mBuilder.setPriority(Notification.PRIORITY_HIGH);
}
if (sound != null) {
mBuilder.setSound(sound);
} else {
if (_pref.getString("notify_sound", AnotherRSS.Config.DEFAULT_notifySound).equals("1")) {
// default Handy sound
sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
mBuilder.setSound(sound);
}
// no sound
}
switch (_notifyType) {
case 1:
mBuilder.setLights(_notifyColor, 1000, 0);
break;
case 2:
mBuilder.setLights(_notifyColor, 4000, 1000);
break;
case 3:
mBuilder.setLights(_notifyColor, 500, 200);
break;
default:
}
Notification noti = mBuilder.build();
noti.flags |= Notification.FLAG_AUTO_CANCEL;
NotificationManager mNotifyMgr =
(NotificationManager) _ctx.getSystemService(Context.NOTIFICATION_SERVICE);
mNotifyMgr.notify(cv.getAsInteger(FeedContract.Feeds._ID), noti);
}