当前位置: 首页>>代码示例>>Java>>正文


Java BigTextStyle类代码示例

本文整理汇总了Java中android.support.v4.app.NotificationCompat.BigTextStyle的典型用法代码示例。如果您正苦于以下问题:Java BigTextStyle类的具体用法?Java BigTextStyle怎么用?Java BigTextStyle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BigTextStyle类属于android.support.v4.app.NotificationCompat包,在下文中一共展示了BigTextStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createBigTextStyleNotification

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:25,代码来源:BaseNotifications.java

示例2: showAuthenticationErrorNotification

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
public void showAuthenticationErrorNotification(Account account, boolean incoming) {
    int notificationId = NotificationIds.getAuthenticationErrorNotificationId(account, incoming);
    Context context = controller.getContext();

    PendingIntent editServerSettingsPendingIntent = createContentIntent(context, account, incoming);
    String title = context.getString(R.string.notification_authentication_error_title);
    String text = context.getString(R.string.notification_authentication_error_text, account.getDescription());

    NotificationCompat.Builder builder = controller.createNotificationBuilder()
            .setSmallIcon(R.drawable.notification_icon_warning)
            .setWhen(System.currentTimeMillis())
            .setAutoCancel(true)
            .setTicker(title)
            .setContentTitle(title)
            .setContentText(text)
            .setContentIntent(editServerSettingsPendingIntent)
            .setStyle(new BigTextStyle().bigText(text))
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setCategory(NotificationCompat.CATEGORY_ERROR);

    controller.configureNotification(builder, null, null,
            NOTIFICATION_LED_FAILURE_COLOR,
            NOTIFICATION_LED_BLINK_FAST, true);

    getNotificationManager().notify(notificationId, builder.build());
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:27,代码来源:AuthenticationErrorNotifications.java

示例3: testCreateBigTextStyleNotification

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
@Test
public void testCreateBigTextStyleNotification() throws Exception {
    Account account = createFakeAccount();
    int notificationId = 23;
    NotificationHolder holder = createNotificationHolder(notificationId);

    Builder builder = notifications.createBigTextStyleNotification(account, holder, notificationId);

    verify(builder).setTicker(NOTIFICATION_SUMMARY);
    verify(builder).setGroup("newMailNotifications-" + ACCOUNT_NUMBER);
    verify(builder).setContentTitle(SENDER);
    verify(builder).setContentText(SUBJECT);
    verify(builder).setSubText(ACCOUNT_NAME);

    BigTextStyle bigTextStyle = notifications.bigTextStyle;
    verify(bigTextStyle).bigText(NOTIFICATION_PREVIEW);

    verify(builder).setStyle(bigTextStyle);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:20,代码来源:BaseNotificationsTest.java

示例4: update

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
/**
 * Updated the notification data copy and also updates the notification in the notification
 * shade.
 * <br />
 * All the extension data is consumed and used for building the notification. The title of the
 * extension data becomes the notification's title, the body of the extension data becomes the
 * notification's content, the click intent of the extension data becomes the notification's
 * click intent, the icon of the extension data becomes the notification's icon and the status
 * of the extension data becomes the notifications info only if the status does not match the
 * title or the body (to prevent redundant information cluttering up the notification.)
 *
 * @param component the component name of the extension
 * @param data      the data passed from the extension
 */
@SuppressWarnings("deprecation")
private void update(ComponentName component, ExtensionData data) {
    if (data != null && data.visible()) {

        int colour = getResources().getColor(R.color.notification_color);
        NotificationCompat.Builder notification = new NotificationCompat.Builder(this);
        notification.setColor(colour);
        notification.setCategory(NotificationCompat.CATEGORY_SERVICE);
        notification.setPriority(Integer.MIN_VALUE);
        notification.setOnlyAlertOnce(true);
        notification.setOngoing(true);
        notification.setShowWhen(true);

        PendingIntent click = PendingIntent.getActivity(getApplicationContext(), 0, data.clickIntent(), 0);
        Bitmap icon = Utils.loadExtensionIcon(getApplicationContext(), component, data.icon(), null, colour);
        notification.setStyle(new BigTextStyle().bigText(data.expandedBody()));
        notification.setSmallIcon(R.drawable.ic_notification);
        notification.setContentTitle(data.expandedTitle());
        notification.setContentText(data.expandedBody());
        notification.setGroup("dashbar");

        if (data.status() != null && !data.status().equalsIgnoreCase(data.expandedBody())
                && !data.status().equalsIgnoreCase(data.expandedTitle())) {
            notification.setContentInfo(data.status());
        }
        notification.setContentIntent(click);
        notification.setLargeIcon(icon);
        mNotifier.notify(component.getPackageName(), 1, notification.build());
    }
}
 
开发者ID:mridang,项目名称:dashbar,代码行数:45,代码来源:NotificationService.java

示例5: generateStyle

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
private static void generateStyle(NotificationCompat.Builder builder) {
    Integer styleValue = STYLE.getValueInt();

    if (STYLE_BIG_PICTURE.equals(styleValue)) {
        BigPictureStyle bigPicture = new NotificationCompat.BigPictureStyle();
        if (PICTURE.hasValue())
            bigPicture.bigPicture(PICTURE.getValueBitmap());
        if (BIG_CONTENT_TITLE.hasValue())
            bigPicture.setBigContentTitle(BIG_CONTENT_TITLE.getValueString());
        if (SUMMARY_TEXT.hasValue())
            bigPicture.setSummaryText(SUMMARY_TEXT.getValueString());
        builder.setStyle(bigPicture);
    } else if (STYLE_BIG_TEXT.equals(styleValue)) {
        BigTextStyle bigText = new NotificationCompat.BigTextStyle();
        if (BIG_TEXT.hasValue())
            bigText.bigText(BIG_TEXT.getValueString());
        if (BIG_CONTENT_TITLE.hasValue())
            bigText.setBigContentTitle(BIG_CONTENT_TITLE.getValueString());
        if (SUMMARY_TEXT.hasValue())
            bigText.setSummaryText(SUMMARY_TEXT.getValueString());
        builder.setStyle(bigText);
    } else if (STYLE_INBOX.equals(styleValue)) {
        InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
        if (LINES.hasValue()) {
            for (String line : LINES.getValueString().split("\\n")) {
                inboxStyle.addLine(line);
            }
        }
        if (BIG_CONTENT_TITLE.hasValue())
            inboxStyle.setBigContentTitle(BIG_CONTENT_TITLE.getValueString());
        if (SUMMARY_TEXT.hasValue())
            inboxStyle.setSummaryText(SUMMARY_TEXT.getValueString());
        builder.setStyle(inboxStyle);
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:NotificationGenerator.java

示例6: fallbackNotify

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
private void fallbackNotify( long id, String title, String desc, PendingIntent contentIntent, PendingIntent sharePi, PendingIntent facebookPi ) {
	mNotifyBuilder = new NotificationCompat.Builder( this ).setWhen( id ).setSmallIcon( R.drawable.ic_push_notify ).setTicker( title )
			.setContentTitle( title ).setContentText( desc ).setStyle( new BigTextStyle().bigText( desc ).setBigContentTitle( title ) )
			.setAutoCancel( true ).addAction( R.drawable.ic_action_social_share, getString( R.string.action_share ), sharePi ).addAction(
					R.drawable.ic_stat_f, getString( R.string.action_fb ), facebookPi );
	mNotifyBuilder.setContentIntent( contentIntent );
	mNotificationManager.notify( Utils.randInt( 1, 9999 ), mNotifyBuilder.build() );
}
 
开发者ID:XinyueZ,项目名称:cusnews,代码行数:9,代码来源:MyGcmListenerService.java

示例7: MorePagesWearNotificationView

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
private void MorePagesWearNotificationView() {

        // Create builder for the main notification
        Intent viewIntent = new Intent(this, SpecialActivity.class);
        PendingIntent viewPendingIntent = PendingIntent.getActivity(this, 0, viewIntent, 0);

        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.ic_launcher).setContentTitle("第一页")
                .setContentText("亲,还有第二页噢").setContentIntent(viewPendingIntent);

        // Create a big text style for the second page
        BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();
        secondPageStyle.setBigContentTitle("第二页").bigText(
                "这是一段很长的Text,用来测试用!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

        // Create second page notification
        Notification secondPageNotification = new NotificationCompat.Builder(this).setStyle(
                secondPageStyle).build();

        // Add second page with wearable extender and extend the main
        // notification
        Notification twoPageNotification = new WearableExtender().addPage(secondPageNotification)
                .extend(notificationBuilder).build();

        // Issue the notification
        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
        notificationManager.notify(NOTIFICATION_ID_5, twoPageNotification);
        manager.cancel(NOTIFICATION_ID_4);

        manager.cancel(NOTIFICATION_ID_6);
        manager.cancel(NOTIFICATION_ID_3);
        manager.cancel(NOTIFICATION_ID_2);
        manager.cancel(NOTIFICATION_ID_1);

    }
 
开发者ID:AndroidWearDemo,项目名称:AndroidWearNotification,代码行数:36,代码来源:MainActivity.java

示例8: BigWearNotificationView

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
private void BigWearNotificationView() {
    Intent mapIntent = new Intent(Intent.ACTION_VIEW);
    // 添加一个在地图上查看事件位置的action
    String location = "Beijing";
    Uri geoUri = Uri.parse("geo:0,0?q=" + Uri.encode(location));
    mapIntent.setData(geoUri);
    PendingIntent mapPendingIntent = PendingIntent.getActivity(this, 0, mapIntent, 0);

    BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
    bigStyle.bigText("这是一个很长的text,用来做测试用!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher)
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher))
            .setContentTitle("消息标题").setContentText("消息正文").setContentIntent(mapPendingIntent)
            .addAction(R.drawable.ic_launcher, getString(R.string.map), mapPendingIntent)
            .setStyle(bigStyle);
            
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
    notificationManager.notify(NOTIFICATION_ID_4, notificationBuilder.build());
    manager.cancel(NOTIFICATION_ID_3);
    manager.cancel(NOTIFICATION_ID_5);

    manager.cancel(NOTIFICATION_ID_6);
    manager.cancel(NOTIFICATION_ID_2);
    manager.cancel(NOTIFICATION_ID_1);
}
 
开发者ID:AndroidWearDemo,项目名称:AndroidWearNotification,代码行数:28,代码来源:MainActivity.java

示例9: buildNotificationCommon

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
/**
 * Get the {@link android.support.v4.app.NotificationCompat.Builder} of {@link android.app.Notification}.
 *
 * @param cxt
 * 		{@link android.content.Context}.
 * @param ticker
 * 		Text shows on notification.
 * @param smallIcon
 * 		Icon for the notification.
 * @param contentTitle
 * 		Text shows above the content.
 * @param content
 * 		Text shows when expand notification.
 * @param id
 * 		The id of this notification.
 * @param bigText
 * 		Some more information.
 *
 * @return A {@link android.support.v4.app.NotificationCompat.Builder}.
 */
private static NotificationCompat.Builder buildNotificationCommon(Context cxt, String ticker,
		@DrawableRes int smallIcon, String contentTitle, String content, int id, String bigText) {
	NotificationCompat.Builder builder = new NotificationCompat.Builder(cxt).setWhen(System.currentTimeMillis())
			.setTicker(ticker).setAutoCancel(true).setSmallIcon(smallIcon).setLargeIcon(
					BitmapFactory.decodeResource(cxt.getResources(), R.drawable.ic_action_logo)).setContentIntent(
					createMainPendingIntent(cxt, id)).setContentTitle(contentTitle).setContentText(content);

	AudioManager audioManager = (AudioManager) cxt.getSystemService(Context.AUDIO_SERVICE);
	if (audioManager.getRingerMode() == RINGER_MODE_VIBRATE) {
		builder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000, 1000, 1000 });
	}
	if (audioManager.getRingerMode() == RINGER_MODE_NORMAL) {
		builder.setSound(Uri.parse(String.format("android.resource://%s/%s", cxt.getPackageName(),
				R.raw.sound_bell)));
	}
	builder.setLights(Color.BLUE, 3000, 3000);

	if (!TextUtils.isEmpty(bigText)) {
		BigTextStyle inboxStyle = new NotificationCompat.BigTextStyle();
		inboxStyle.setBigContentTitle(contentTitle);
		inboxStyle.bigText(bigText);
		inboxStyle.setSummaryText(content);
		builder.setStyle(inboxStyle);
	}
	return builder;
}
 
开发者ID:XinyueZ,项目名称:schautup,代码行数:47,代码来源:App.java

示例10: bigTextNoti

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
void bigTextNoti() {
	//create the intent to launch the notiactivity, then the pentingintent.
	Intent viewIntent = new Intent(this, NotiActivity.class);
	viewIntent.putExtra("NotiID", "Notification ID is " + notificationID);
	
	PendingIntent viewPendingIntent =
	        PendingIntent.getActivity(this, 0, viewIntent, 0);

	BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
	bigStyle.bigText("Big text style.\n"
			+ "We should have more room to add text for the user to read, instead of a short message.");

	
	//Now create the notification.  We must use the NotificationCompat or it will not work on the wearable.
	NotificationCompat.Builder notificationBuilder =
	        new NotificationCompat.Builder(this)
	        .setSmallIcon(R.drawable.ic_launcher)
	        .setContentTitle("Simple Noti")
	        .setContentText("This is a simple notification")
	        .setContentIntent(viewPendingIntent)
	        .setStyle(bigStyle);

	// Get an instance of the NotificationManager service
	NotificationManagerCompat notificationManager =
	        NotificationManagerCompat.from(this);

	// Build the notification and issues it with notification manager.
	notificationManager.notify(notificationID, notificationBuilder.build());
	notificationID++;
}
 
开发者ID:JimSeker,项目名称:wearable,代码行数:31,代码来源:MainActivity.java

示例11: bigTextNoti

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
void bigTextNoti() {
    //create the intent to launch the notiactivity, then the pentingintent.
    Intent viewIntent = new Intent(this, NotiActivity.class);
    viewIntent.putExtra("NotiID", "Notification ID is " + notificationID);

    PendingIntent viewPendingIntent =
        PendingIntent.getActivity(this, 0, viewIntent, 0);

    BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
    bigStyle.bigText("Big text style.\n"
        + "We should have more room to add text for the user to read, instead of a short message.");


    //Now create the notification.  We must use the NotificationCompat or it will not work on the wearable.
    NotificationCompat.Builder notificationBuilder =
        new NotificationCompat.Builder(this, id)
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle("Simple Noti")
            .setContentText("This is a simple notification")
            .setContentIntent(viewPendingIntent)
            .setChannelId(id)
            .setStyle(bigStyle);

    // Get an instance of the NotificationManager service
    NotificationManagerCompat notificationManager =
        NotificationManagerCompat.from(this);

    // Build the notification and issues it with notification manager.
    notificationManager.notify(notificationID, notificationBuilder.build());
    notificationID++;
}
 
开发者ID:JimSeker,项目名称:wearable,代码行数:32,代码来源:MainActivity.java

示例12: createBigTextStyle

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
protected BigTextStyle createBigTextStyle(Builder builder) {
    return new BigTextStyle(builder);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:4,代码来源:BaseNotifications.java

示例13: createBigTextStyle

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
@Override
protected BigTextStyle createBigTextStyle(Builder builder) {
    return bigTextStyle;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:5,代码来源:DeviceNotificationsTest.java

示例14: TestNotifications

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
protected TestNotifications(NotificationController controller, NotificationActionCreator actionCreator) {
    super(controller, actionCreator);
    bigTextStyle = mock(BigTextStyle.class);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:5,代码来源:BaseNotificationsTest.java

示例15: sendSingleThreadNotification

import android.support.v4.app.NotificationCompat.BigTextStyle; //导入依赖的package包/类
private static void sendSingleThreadNotification(Context context,
                                                 MasterSecret masterSecret,
                                                 NotificationState notificationState,
                                                 boolean signal)
{
  if (notificationState.getNotifications().isEmpty()) {
    ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
        .cancel(NOTIFICATION_ID);
    return;
  }

  List<NotificationItem>notifications = notificationState.getNotifications();
  NotificationCompat.Builder builder  = new NotificationCompat.Builder(context);
  Recipient recipient                 = notifications.get(0).getIndividualRecipient();

  builder.setSmallIcon(R.drawable.icon_notification);
  builder.setLargeIcon(recipient.getContactPhoto());
  builder.setContentTitle(recipient.toShortString());
  builder.setContentText(notifications.get(0).getText());
  builder.setContentIntent(notifications.get(0).getPendingIntent(context));
  builder.setContentInfo(String.valueOf(notificationState.getMessageCount()));
  builder.setNumber(notificationState.getMessageCount());
  builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(DeleteReceiver.DELETE_REMINDER_ACTION), 0));

  if (masterSecret != null) {
    builder.addAction(R.drawable.check, context.getString(R.string.MessageNotifier_mark_as_read),
                      notificationState.getMarkAsReadIntent(context, masterSecret));
  }

  SpannableStringBuilder content = new SpannableStringBuilder();

  ListIterator<NotificationItem> iterator = notifications.listIterator(notifications.size());
  while(iterator.hasPrevious()) {
    NotificationItem item = iterator.previous();
    content.append(item.getBigStyleSummary());
    content.append('\n');
  }

  builder.setStyle(new BigTextStyle().bigText(content));

  setNotificationAlarms(context, builder, signal);

  if (signal) {
    builder.setTicker(notifications.get(0).getTickerText());
  }

  ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
    .notify(NOTIFICATION_ID, builder.build());
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:50,代码来源:MessageNotifier.java


注:本文中的android.support.v4.app.NotificationCompat.BigTextStyle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。