Java 类android.support.v4.app.NotificationCompat.Builder 实例源码

项目:XERUNG    文件:ContactSync.java   
private void backupFound(){
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
    if(jbBackupM.toString().trim().length()>0){
        Intent dialogIntent = new Intent(this, AddToContactList.class);
        dialogIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        dialogIntent.putExtra("data", jbBackupM.toString());
        PendingIntent intent = PendingIntent.getActivity(this, 0, dialogIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        mBuilder.setContentIntent(intent);
    }
    mBuilder.setSmallIcon(R.drawable.ic_custom_notification);
    mBuilder.setAutoCancel(true);
    mBuilder.setContentTitle("Contact Sync!!");
    mBuilder.setContentText("You have lost some contact, we have backup");
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    // notificationID allows you to update the notification later on.
    mNotificationManager.notify(notificaitonId, mBuilder.build());
}
项目:q-mail    文件:DeviceNotifications.java   
private NotificationCompat.Builder createSimpleSummaryNotification(Account account, int unreadMessageCount) {
    String accountName = controller.getAccountName(account);
    CharSequence newMailText = context.getString(R.string.notification_new_title);
    String unreadMessageCountText = context.getResources().getQuantityString(R.plurals.notification_new_one_account_fmt,
            unreadMessageCount, unreadMessageCount, accountName);

    int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
    PendingIntent contentIntent = actionCreator.createViewFolderListPendingIntent(account, notificationId);

    return createAndInitializeNotificationBuilder(account)
            .setNumber(unreadMessageCount)
            .setTicker(newMailText)
            .setContentTitle(unreadMessageCountText)
            .setContentText(newMailText)
            .setContentIntent(contentIntent);
}
项目:q-mail    文件:WearNotifications.java   
public void addSummaryActions(Builder builder, NotificationData notificationData) {
    NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();

    addMarkAllAsReadAction(wearableExtender, notificationData);

    if (isDeleteActionAvailableForWear()) {
        addDeleteAllAction(wearableExtender, notificationData);
    }

    Account account = notificationData.getAccount();
    if (isArchiveActionAvailableForWear(account)) {
        addArchiveAllAction(wearableExtender, notificationData);
    }

    builder.extend(wearableExtender);
}
项目:q-mail    文件:WearNotifications.java   
private void addWearActions(Builder builder, Account account, NotificationHolder holder) {
    NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();

    addReplyAction(wearableExtender, holder);
    addMarkAsReadAction(wearableExtender, holder);

    if (isDeleteActionAvailableForWear()) {
        addDeleteAction(wearableExtender, holder);
    }

    if (isArchiveActionAvailableForWear(account)) {
        addArchiveAction(wearableExtender, holder);
    }

    if (isSpamActionAvailableForWear(account)) {
        addMarkAsSpamAction(wearableExtender, holder);
    }

    builder.extend(wearableExtender);
}
项目:q-mail    文件:BaseNotifications.java   
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;
}
项目:q-mail    文件:BaseNotificationsTest.java   
@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);
}
项目:XERUNG    文件:ContactSync.java   
private void backupFound(){
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
    if(jbBackupM.toString().trim().length()>0){
        Intent dialogIntent = new Intent(this, AddToContactList.class);
        dialogIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        dialogIntent.putExtra("data", jbBackupM.toString());
        PendingIntent intent = PendingIntent.getActivity(this, 0, dialogIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        mBuilder.setContentIntent(intent);
    }
    mBuilder.setSmallIcon(R.drawable.ic_custom_notification);
    mBuilder.setAutoCancel(true);
    mBuilder.setContentTitle("Contact Sync!!");
    mBuilder.setContentText("You have lost some contact, we have backup");
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    // notificationID allows you to update the notification later on.
    mNotificationManager.notify(notificaitonId, mBuilder.build());
}
项目:aos-Video    文件:FileManagerService.java   
private void displayOpenFileNotification() {
    Intent notificationIntent = getOpenIntent();
    int icon =  R.mipmap.video2;
    CharSequence title = getResources().getText(R.string.open_file);
    long when = System.currentTimeMillis();
    PendingIntent contentIntent = PendingIntent.getBroadcast(this, 0, notificationIntent, 0);
    Builder notificationBuilder = new NotificationCompat.Builder(this);
    notificationBuilder.setSmallIcon(icon);
    notificationBuilder.setTicker(null);
    notificationBuilder.setOnlyAlertOnce(true);
    notificationBuilder.setContentTitle(title);
    notificationBuilder.setContentText(mProcessedFiles.get(0).getName());
    notificationBuilder.setContentIntent(contentIntent);
    notificationBuilder.setWhen(when);
    notificationBuilder.setDefaults(0); // no sound, no light, no vibrate
    mNotificationManager.notify(OPEN_NOTIFICATION_ID, notificationBuilder.build());
}
项目:boohee_v5.6    文件:UpdateService.java   
private void download(UpdateInfo info) {
    if (info == null || TextUtils.isEmpty(info.apk_url) || TextUtils.isEmpty(info.new_md5)) {
        stopSelf();
        return;
    }
    File folder = UpdateUtil.getUpdateDir(this);
    String title = info.new_md5 + ShareConstants.PATCH_SUFFIX;
    DownloadRequest request = new DownloadRequest.Builder().setTitle(title).setFolder(folder)
            .setUri(info.apk_url).build();
    File downloadFile = new File(folder, title);
    Builder builder = new Builder(this);
    builder.setSmallIcon(17301633).setContentTitle("薄荷").setContentText("开始下载").setProgress
            (100, 0, true).setTicker("正在下载薄荷");
    startForeground(4096, builder.build());
    this.sDownloadManager.download(request, info.apk_url, new UpdateDownloadCallback(this,
            downloadFile, info, builder));
}
项目:boohee_v5.6    文件:StepCounterService.java   
private void initNotification() {
    if (StepsPreference.isStepNotificationOpen()) {
        this.showTaskIntent = new Intent(getApplicationContext(), MainActivity.class);
        this.showTaskIntent.setAction("android.intent.action.MAIN");
        this.showTaskIntent.addCategory("android.intent.category.LAUNCHER");
        this.showTaskIntent.addFlags(268435456);
        this.contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, this
                .showTaskIntent, 134217728);
        this.builder = new Builder(getApplicationContext()).setContentTitle(getString(R
                .string.a78)).setWhen(System.currentTimeMillis()).setContentIntent(this
                .contentIntent).setLargeIcon(BitmapFactory.decodeResource(getResources(), R
                .drawable.icon));
        if (VERSION.SDK_INT >= 21) {
            this.builder.setColor(ContextCompat.getColor(this, R.color.hb)).setSmallIcon(R
                    .drawable.qm);
        } else {
            this.builder.setSmallIcon(R.drawable.icon);
        }
    }
}
项目:boohee_v5.6    文件:StatusPostTextActivity.java   
private void init() {
    this.mActivity = this;
    this.mNotificationManager = (NotificationManager) getSystemService("notification");
    this.mNFBuilder = new Builder(this.ctx);
    this.group_id = getIntExtra(Const.GROUP_ID);
    ArrayList<String> tempList = getIntent().getStringArrayListExtra(KEY_SELECTED_PICTURES);
    if (tempList != null && tempList.size() > 0) {
        this.mSelectPictures.clear();
        this.mSelectPictures.addAll(0, tempList);
        this.mSelectPictures.add("add");
    }
    initSendApi();
    if (getIntent() != null) {
        this.attachMent = (AttachMent) getIntent().getParcelableExtra(EXTRA_ATTACHMENT);
    }
    restoreDraft();
    initPicGridView();
    if (this.attachMent != null) {
        this.attachmentLayout.setVisibility(0);
        this.imageLoader.displayImage(this.attachMent.pic, this.ivAttachment);
        this.tvAttachment.setText(this.attachMent.title);
    }
    initEmoji();
    handlePictureURL();
}
项目:TenguChat    文件:NotificationService.java   
public Notification createForegroundNotification() {
    final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);

    mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service));
    if (Config.SHOW_CONNECTED_ACCOUNTS) {
        List<Account> accounts = mXmppConnectionService.getAccounts();
        int enabled = 0;
        int connected = 0;
        for (Account account : accounts) {
            if (account.isOnlineAndConnected()) {
                connected++;
                enabled++;
            } else if (!account.isOptionSet(Account.OPTION_DISABLED)) {
                enabled++;
            }
        }
        mBuilder.setContentText(mXmppConnectionService.getString(R.string.connected_accounts, connected, enabled));
    } else {
        mBuilder.setContentText(mXmppConnectionService.getString(R.string.touch_to_open_conversations));
    }
    mBuilder.setContentIntent(createOpenConversationsIntent());
    mBuilder.setWhen(0);
    mBuilder.setPriority(Config.SHOW_CONNECTED_ACCOUNTS ? NotificationCompat.PRIORITY_DEFAULT : NotificationCompat.PRIORITY_MIN);
    mBuilder.setSmallIcon(R.drawable.ic_link_white_24dp);
    return mBuilder.build();
}
项目:nuclei-android    文件:NotificationBuilder.java   
public Notification buildSummary(Context context, NotificationManager manager, String group, List<NotificationMessage> messages) {
    NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender();

    Intent intent = new Intent(context, NotificationIntentService.class);
    manager.setCancelAll(intent, group);
    intent.setData(Uri.parse("nuclei://notifications?_g=" + group));
    PendingIntent pendingIntent = PendingIntent.getService(context, getDeleteIntentRequestId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);

    Builder builder = new Builder(context)
            .setSmallIcon(manager.getDefaultSmallIcon())
            .setLargeIcon(manager.getDefaultLargeIcon())
            .setAutoCancel(true)
            .setGroup(group)
            .setGroupSummary(true);

    onBuildSummary(context, manager, builder, extender, group, messages);

    builder.setDeleteIntent(pendingIntent);

    extender.extend(builder);

    return builder.build();
}
项目:nuclei-android    文件:NotificationBuilder.java   
public Notification buildNotification(Context context, NotificationManager manager, NotificationMessage message, List<NotificationMessage> messages) {
    NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender();

    Intent intent = new Intent(context, NotificationIntentService.class);
    manager.setCancelMessage(intent, message);
    intent.setData(Uri.parse("nuclei://notifications?_id=" + message._id + "&_g=" + message.groupKey));
    PendingIntent pendingIntent = PendingIntent.getService(context, getDeleteIntentRequestId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);

    Builder builder = new Builder(context)
            .setSmallIcon(manager.getDefaultSmallIcon())
            .setLargeIcon(manager.getDefaultLargeIcon())
            .setOngoing(false)
            .setAutoCancel(true);

    if (messages.size() > 1) {
        builder.setGroup(message.groupKey).setGroupSummary(false);
    }

    onBuildNotification(context, manager, builder, extender, message);

    builder.setDeleteIntent(pendingIntent);

    extender.extend(builder);

    return builder.build();
}
项目:K9-MailClient    文件:DeviceNotifications.java   
private NotificationCompat.Builder createSimpleSummaryNotification(Account account, int unreadMessageCount) {
    String accountName = controller.getAccountName(account);
    CharSequence newMailText = context.getString(R.string.notification_new_title);
    String unreadMessageCountText = context.getString(R.string.notification_new_one_account_fmt,
            unreadMessageCount, accountName);

    int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
    PendingIntent contentIntent = actionCreator.createViewFolderListPendingIntent(account, notificationId);

    return createAndInitializeNotificationBuilder(account)
            .setNumber(unreadMessageCount)
            .setTicker(newMailText)
            .setContentTitle(unreadMessageCountText)
            .setContentText(newMailText)
            .setContentIntent(contentIntent);
}
项目:K9-MailClient    文件:WearNotifications.java   
public void addSummaryActions(Builder builder, NotificationData notificationData) {
    NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();

    addMarkAllAsReadAction(wearableExtender, notificationData);

    if (isDeleteActionAvailableForWear()) {
        addDeleteAllAction(wearableExtender, notificationData);
    }

    Account account = notificationData.getAccount();
    if (isArchiveActionAvailableForWear(account)) {
        addArchiveAllAction(wearableExtender, notificationData);
    }

    builder.extend(wearableExtender);
}
项目:K9-MailClient    文件:WearNotifications.java   
private void addWearActions(Builder builder, Account account, NotificationHolder holder) {
    NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();

    addReplyAction(wearableExtender, holder);
    addMarkAsReadAction(wearableExtender, holder);

    if (isDeleteActionAvailableForWear()) {
        addDeleteAction(wearableExtender, holder);
    }

    if (isArchiveActionAvailableForWear(account)) {
        addArchiveAction(wearableExtender, holder);
    }

    if (isSpamActionAvailableForWear(account)) {
        addMarkAsSpamAction(wearableExtender, holder);
    }

    builder.extend(wearableExtender);
}
项目:K9-MailClient    文件:BaseNotifications.java   
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;
}
项目:K9-MailClient    文件:BaseNotificationsTest.java   
@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);
}
项目:FMTech    文件:NotificationManager.java   
private void showStorageFullAlertOrNotification$fb5dc8d(String paramString1, String paramString2, String paramString3, String paramString4, boolean paramBoolean)
{
  if ((this.mListener != null) && (!this.mListener.shouldShowAppNotification$14e1ec69(paramString1)))
  {
    if (FinskyApp.get().getExperiments().isEnabled(12603367L))
    {
      this.mListener.showAppAlert(paramString1, paramString3, paramString4, 3);
      return;
    }
    if (paramBoolean) {}
    for (int i = 47;; i = 48)
    {
      ErrorDialog.Builder localBuilder = (ErrorDialog.Builder)((ErrorDialog.Builder)((ErrorDialog.Builder)((ErrorDialog.Builder)((ErrorDialog.Builder)((ErrorDialog.Builder)new ErrorDialog.Builder().setTitle(paramString3)).setMessageHtml(paramString4)).setPositiveId(2131362841)).setNegativeId(2131361915)).setCallback(null, i, null)).setEventLog(324, null, 2904, 2903, null);
      this.mListener.showAppAlert(paramString1, localBuilder);
      return;
    }
  }
  showAppNotificationOnly$1f519fb9(paramString1, paramString2, paramString3, paramString4, -1, "err");
}
项目:flowzr-android-black    文件:FlowzrBillTask.java   
protected void onPostExecute(Boolean result) {
final FlowzrBilling b = new FlowzrBilling(context, http_client, "", MyPreferences.getFlowzrAccount(context));
Thread thread = new Thread(new Runnable(){
    @Override
    public void run() {
        try {
                if (b.checkSubscription()) {
                    ((Activity) context).runOnUiThread(new Runnable(){
                        public void run(){
                        new AlertDialog.Builder(context)
                        .setMessage(R.string.flowzr_account_setup)
                        .setTitle(R.string.info)
                        .setPositiveButton(R.string.ok, null)
                        .setCancelable(true)
                        .create().show();
                        }
                    });
                }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
});

thread.start(); 
        }
项目:wordpress_app_android    文件:PostUploadService.java   
public PostUploadNotifier(Post post) {
    // add the uploader to the notification bar
    mNotificationManager = (NotificationManager) SystemServiceFactory.get(mContext,
            Context.NOTIFICATION_SERVICE);

    mNotificationBuilder = new NotificationCompat.Builder(getApplicationContext());
    mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_upload);

    Intent notificationIntent = new Intent(mContext, post.isPage() ? PagesActivity.class : PostsActivity.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
            | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    notificationIntent.setData((Uri.parse("custom://wordpressNotificationIntent"
            + post.getLocalTableBlogId())));
    notificationIntent.putExtra(PostsActivity.EXTRA_VIEW_PAGES, post.isPage());
    PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    mNotificationBuilder.setContentIntent(pendingIntent);

    mNotificationId = (new Random()).nextInt() + post.getLocalTableBlogId();
    startForeground(mNotificationId, mNotificationBuilder.build());
}
项目:beaconloc    文件:NotificationBuilder.java   
/**
 * Creation of notification on operations completed
 */
public NotificationBuilder createNotification(int smallIcon, String title, PendingIntent notifyIntent) {
    mBuilder = new NotificationCompat.Builder(mContext).setSmallIcon(smallIcon).setContentTitle(title)
            .setAutoCancel(true).setColor(ContextCompat.getColor(mContext, R.color.hn_orange));
    if (notifyIntent != null) {
        mBuilder.setContentIntent(notifyIntent);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // setLargeIcon(R.drawable.logo_notification_lollipop);
        //FIXME
        setLargeIcon(R.mipmap.ic_launcher);
    } else {
        setLargeIcon(R.mipmap.ic_launcher);
    }

    return this;
}
项目:Pix-Art-Messenger    文件:NotificationService.java   
private void modifyForSoundVibrationAndLight(Builder mBuilder, boolean notify, SharedPreferences preferences) {
    final Resources resources = mXmppConnectionService.getResources();
    final String ringtone = preferences.getString("notification_ringtone", resources.getString(R.string.notification_ringtone));
    final boolean vibrate = preferences.getBoolean("vibrate_on_notification", resources.getBoolean(R.bool.vibrate_on_notification));
    final boolean led = preferences.getBoolean("led", resources.getBoolean(R.bool.led));
    final boolean headsup = preferences.getBoolean("notification_headsup", resources.getBoolean(R.bool.headsup_notifications));
    if (notify && !isQuietHours()) {
        if (vibrate) {
            final int dat = 70;
            final long[] pattern = {0, 3 * dat, dat, dat};
            mBuilder.setVibrate(pattern);
        } else {
            mBuilder.setVibrate(new long[]{0});
        }
        Uri uri = Uri.parse(ringtone);
        try {
            mBuilder.setSound(fixRingtoneUri(uri));
        } catch (SecurityException e) {
            Log.d(Config.LOGTAG, "unable to use custom notification sound " + uri.toString());
        }
    }
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mBuilder.setCategory(Notification.CATEGORY_MESSAGE);
    }
    mBuilder.setPriority(notify ? (headsup ? NotificationCompat.PRIORITY_HIGH : NotificationCompat.PRIORITY_DEFAULT) : NotificationCompat.PRIORITY_LOW);
    setNotificationColor(mBuilder);
    mBuilder.setDefaults(0);
    if (led) {
        mBuilder.setLights(0xff0080FF, 2000, 3000);
    }
}
项目:mc_backup    文件:UpdateService.java   
private void showDownloadNotification(File downloadFile) {

        Intent notificationIntent = new Intent(UpdateServiceHelper.ACTION_APPLY_UPDATE);
        notificationIntent.setClass(this, UpdateService.class);

        Intent cancelIntent = new Intent(UpdateServiceHelper.ACTION_CANCEL_DOWNLOAD);
        cancelIntent.setClass(this, UpdateService.class);

        if (downloadFile != null)
            notificationIntent.putExtra(UpdateServiceHelper.EXTRA_PACKAGE_PATH_NAME, downloadFile.getAbsolutePath());

        PendingIntent contentIntent = PendingIntent.getService(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        PendingIntent deleteIntent = PendingIntent.getService(this, 0, cancelIntent, PendingIntent.FLAG_CANCEL_CURRENT);

        mBuilder = new NotificationCompat.Builder(this);
        mBuilder.setContentTitle(getResources().getString(R.string.updater_downloading_title))
                .setContentText(mApplyImmediately ? "" : getResources().getString(R.string.updater_downloading_select))
                .setSmallIcon(android.R.drawable.stat_sys_download)
                .setContentIntent(contentIntent)
                .setDeleteIntent(deleteIntent);

        mBuilder.setProgress(100, 0, true);
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }
项目:mobilecloud-15    文件:UploadVideoService.java   
/**
 * Starts the Notification to show the progress of video upload.
 */
private void startNotification() {
    // Gets access to the Android Notification Service.
    mNotifyManager = (NotificationManager)
        getSystemService(Context.NOTIFICATION_SERVICE); 

    // Create the Notification and set a progress indicator for an
    // operation of indeterminate length.
    mBuilder = new NotificationCompat
                   .Builder(this)
                   .setContentTitle("Video Upload") 
                   .setContentText("Upload in progress") 
                   .setSmallIcon(android.R.drawable.stat_sys_upload)
                   .setTicker("Uploading video")
                   .setProgress(0,
                                0,
                                true);

    // Build and issue the notification.
    mNotifyManager.notify(NOTIFICATION_ID,
                          mBuilder.build());
}
项目:mobilecloud-15    文件:UploadVideoService.java   
/**
 * Starts the Notification to show the progress of video upload.
 */
private void startNotification() {
    // Gets access to the Android Notification Service.
    mNotifyManager = (NotificationManager)
        getSystemService(Context.NOTIFICATION_SERVICE); 

    // Create the Notification and set a progress indicator for an
    // operation of indeterminate length.
    mBuilder = new NotificationCompat
                   .Builder(this)
                   .setContentTitle("Video Upload") 
                   .setContentText("Upload in progress") 
                   .setSmallIcon(android.R.drawable.stat_sys_upload)
                   .setTicker("Uploading video")
                   .setProgress(0,
                                0,
                                true);

    // Build and issue the notification.
    mNotifyManager.notify(NOTIFICATION_ID,
                          mBuilder.build());
}
项目:Conversations    文件:NotificationService.java   
public Notification createForegroundNotification() {
    final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);

    mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.conversations_foreground_service));
    if (Config.SHOW_CONNECTED_ACCOUNTS) {
        List<Account> accounts = mXmppConnectionService.getAccounts();
        int enabled = 0;
        int connected = 0;
        for (Account account : accounts) {
            if (account.isOnlineAndConnected()) {
                connected++;
                enabled++;
            } else if (account.isEnabled()) {
                enabled++;
            }
        }
        mBuilder.setContentText(mXmppConnectionService.getString(R.string.connected_accounts, connected, enabled));
    } else {
        mBuilder.setContentText(mXmppConnectionService.getString(R.string.touch_to_open_conversations));
    }
    mBuilder.setContentIntent(createOpenConversationsIntent());
    mBuilder.setWhen(0);
    mBuilder.setPriority(Config.SHOW_CONNECTED_ACCOUNTS ? NotificationCompat.PRIORITY_DEFAULT : NotificationCompat.PRIORITY_MIN);
    mBuilder.setSmallIcon(R.drawable.ic_link_white_24dp);
    return mBuilder.build();
}
项目:ingress-speedwave    文件:SpeedWaveService.java   
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if(this.initial) {
        LOG.d("Speed wave service started");

        this.notificationManager = new SpeedWaveNotificationManager(new Builder(this),
                (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE),
                new IngressIntentBuilder(this));

        this.broadcastManager = LocalBroadcastManager.getInstance(this);
        this.stopReceiver.registerWith(this.broadcastManager);
        this.locationReceiver.registerWith(this.broadcastManager);

        this.scheduler.scheduleAtFixedRate(new SpeedWaveChecker(this.locationManager,
                this, this.notificationManager), 0, 1, TimeUnit.SECONDS);

        this.initial = false;
    }

    this.shouldStop = false;
    this.notificationManager.resetHideNotification();
    return super.onStartCommand(intent, flags, startId);
}
项目:ingress-speedwave    文件:NotificationManagerTest.java   
public void testFastNotificationAndCancel() {
    NotificationManager androidNotiMgr = mockNotificationManager();
    Builder builder = mockBuilder();

    SpeedWaveNotificationManager speedWaveNotiMgr =
            new SpeedWaveNotificationManager(builder, androidNotiMgr, mockIntentBuilder());
    Mockito.verify(androidNotiMgr).notify(0, null);

    speedWaveNotiMgr.onSpeedUpdate(true, 1, 10);
    Mockito.verify(builder).setContentText("00:01");
    Mockito.verify(builder).setProgress(10, 9, false);

    speedWaveNotiMgr.suggestCancel();

    Mockito.verify(androidNotiMgr, Mockito.times(2)).notify(0, null);
    Mockito.verifyNoMoreInteractions(androidNotiMgr);
}
项目:frozenchat    文件:NotificationService.java   
private void modifyForConference(Builder builder, Conversation conversation, List<Message> messages, boolean notify) {
    final Message first = messages.get(0);
    final Message last = messages.get(messages.size() - 1);
    final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
    style.setBigContentTitle(conversation.getName());

    for(Message message : messages) {
        if (message.hasMeCommand()) {
            style.addLine(UIHelper.getMessagePreview(mXmppConnectionService,message).first);
        } else {
            style.addLine(Html.fromHtml("<b>" + UIHelper.getMessageDisplayName(message) + "</b>: " + UIHelper.getMessagePreview(mXmppConnectionService, message).first));
        }
    }
    builder.setContentText((first.hasMeCommand() ? "" :UIHelper.getMessageDisplayName(first)+ ": ") +UIHelper.getMessagePreview(mXmppConnectionService, first).first);
    builder.setStyle(style);
    if (notify) {
        builder.setTicker((last.hasMeCommand() ? "" : UIHelper.getMessageDisplayName(last) + ": ") + UIHelper.getMessagePreview(mXmppConnectionService,last).first);
    }
}
项目:AndroidWearNotifications    文件:NotificationPresets.java   
private static Builder buildBasicNotification(Context context, NotificationPreset.BuildOptions options) {

        NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                .setContentTitle(context.getString(R.string.example_content_title))
                .setContentText(context.getString(R.string.example_content_text))
                .setSmallIcon(R.mipmap.ic_app_notification_studio)
                .setDeleteIntent(NotificationUtil.getExamplePendingIntent(context, R.string.example_notification_deleted));

        options.actionsPreset.apply(context, builder);
        options.priorityPreset.apply(builder);

        if (options.includeLargeIcon) {
            builder.setLargeIcon(BitmapFactory.decodeResource(
                    context.getResources(), R.drawable.example_large_icon));
        }
        if (options.isLocalOnly) {
            builder.setLocalOnly(true);
        }
        if (options.hasContentIntent) {
            builder.setContentIntent(NotificationUtil.getExamplePendingIntent(context, R.string.content_intent_clicked));
        }
        return builder;
    }
项目:AndroidWearNotifications    文件:NotificationPresets.java   
@Override
public Notification[] buildNotifications(Context context, BuildOptions options) {

    Notification secondPage = new NotificationCompat.Builder(context)
            .setContentTitle(context.getString(R.string.second_page_content_title))
            .setContentText(context.getString(R.string.second_page_content_text))
            .build();

    Builder notificationBuilder = buildBasicNotification(context, options);

    Notification twoPageNotification = new WearableExtender()
                    .addPage(secondPage)
                    .extend(notificationBuilder)
                    .build();

    return new Notification[] { twoPageNotification };
}
项目:txtr    文件:NotificationService.java   
private Builder buildSingleConversations(final boolean notify) {
    final Builder mBuilder = new NotificationCompat.Builder(
            mXmppConnectionService);
    final ArrayList<Message> messages = notifications.values().iterator().next();
    if (messages.size() >= 1) {
        final Conversation conversation = messages.get(0).getConversation();
        mBuilder.setLargeIcon(mXmppConnectionService.getAvatarService()
                .get(conversation, getPixel(64)));
        mBuilder.setContentTitle(conversation.getName());
        final Message message;
        if ((message = getImage(messages)) != null) {
            modifyForImage(mBuilder, message, messages, notify);
        } else {
            modifyForTextOnly(mBuilder, messages, notify);
        }
        mBuilder.setContentIntent(createContentIntent(conversation
                    .getUuid()));
    }
    return mBuilder;
}
项目:txtr    文件:NotificationService.java   
private void modifyForImage(final Builder builder, final Message message,
        final ArrayList<Message> messages, final boolean notify) {
    try {
        final Bitmap bitmap = mXmppConnectionService.getFileBackend()
            .getThumbnail(message, getPixel(288), false);
        final ArrayList<Message> tmp = new ArrayList<>();
        for (final Message msg : messages) {
            if (msg.getType() == Message.TYPE_TEXT
                    && msg.getDownloadable() == null) {
                tmp.add(msg);
                    }
        }
        final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
        bigPictureStyle.bigPicture(bitmap);
        if (tmp.size() > 0) {
            bigPictureStyle.setSummaryText(getMergedBodies(tmp));
            builder.setContentText(getReadableBody(tmp.get(0)));
        } else {
            builder.setContentText(mXmppConnectionService.getString(R.string.image_file));
        }
        builder.setStyle(bigPictureStyle);
    } catch (final FileNotFoundException e) {
        modifyForTextOnly(builder, messages, notify);
    }
}
项目:OrbitCat    文件:HttpServerService.java   
private void showNotification() {
    Intent stopIntent = new Intent(getApplicationContext(), HttpServerServiceStopReceiver.class);

    Intent clickIntent = new Intent(getApplicationContext(), MainActivity.class);
    clickIntent.addCategory("android.intent.category.LAUNCHER");
    clickIntent.setAction("android.intent.action.MAIN");
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, clickIntent, 0);

    PendingIntent stopPendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 0, stopIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    Builder builder = new Builder(this)
            .setContentTitle(getString(R.string.notification_title))
            .setContentIntent(contentIntent)
            .setSmallIcon(R.drawable.app_icon)
            .addAction(R.drawable.quit2, getString(R.string.quit), stopPendingIntent)
            .setOngoing(true)
            .setContentText(getString(R.string.notification_content));

    // Send the notification.
    notificationManager.notify(R.string.http_service_notification, builder.build());
}
项目:android-wear-gopro-remote    文件:WearMessageHandlerService.java   
void updateNotification(String contentText) {
    if(mNotificationBuilder == null) {
        Context context = getApplicationContext();
        Intent activityIntent = new Intent(context, MobileMainActivity.class);
        activityIntent.setAction(Intent.ACTION_MAIN);
        activityIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        activityIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NEW_TASK);

        Intent stopIntent = new Intent(context, WearMessageHandlerService.class);
        stopIntent.setAction(ACTION_STOP);

        mNotificationBuilder = (new Builder(this))
                .setSmallIcon(R.drawable.icon_notification)
                .setContentTitle(getString(R.string.notification_tittle))
                .setContentIntent(PendingIntent.getActivity(context, 0, activityIntent, 0))
                .setLocalOnly(true)
                .addAction(R.drawable.icon_power, getString(R.string.action_stop),
                        PendingIntent.getService(context, 0, stopIntent, 0));
    }

    mNotificationBuilder.setContentText(contentText);
    startForeground(1, mNotificationBuilder.build());
}
项目:TvPoo    文件:ConnectionService.java   
@Override
public void onConnectionFailed() {
    Builder builder = new NotificationCompat.Builder(this);
    builder.setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle("Connection failed")
            .setContentText("Permissions need to be granted first");

    Intent intent = new Intent(this, MainActivity.class);
    intent.putExtra(MainActivity.EXTRA_KEY_REAUTHORIZE, true);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(intent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
            PendingIntent.FLAG_UPDATE_CURRENT);

    builder.setContentIntent(resultPendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(42, builder.build());

    stopSelf();
}
项目:androidProject    文件:MainActivity.java   
private void showNotifiRule(Context context) {
    Intent resultIntent = new Intent(context, ResultActivity1.class);
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    // ��Ӻ�̨��ջ
    stackBuilder.addParentStack(ResultActivity1.class);
    // ���Intent��ջ��
    stackBuilder.addNextIntent(resultIntent);
    // ���һ��PendingIntent����������̨��ջ containing the entire back stack
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
            PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(
            context);
    //�������õ�3������
    builder.setSmallIcon(R.drawable.app_window);
    builder.setContentTitle("��Ϣ����");
    builder.setContentText("���ĵ��Գ�������");

    builder.setContentIntent(resultPendingIntent);
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(NOTIFIFIXID, builder.build());
}
项目:androidProject    文件:MainActivity.java   
private void showNotifiGood(Context context) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(
            context);
    Intent notifyIntent = new Intent(context, ResultActivity2.class);
    notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    PendingIntent notifyIntentPending = PendingIntent.getActivity(context,
            0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    //�������õ�3������
    builder.setSmallIcon(R.drawable.app_window);
    builder.setContentTitle("��Ϣ����");
    builder.setContentText("���ĵ��Գ�������");
    builder.setContentIntent(notifyIntentPending);
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(NOTIFIFIXID, builder.build());
}