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


Java NotificationCompat.Action方法代码示例

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


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

示例1: getAction

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private NotificationCompat.Action getAction(AppUpdateStatusManager.AppUpdateStatus entry) {
    if (entry.intent != null) {
        switch (entry.status) {
            case UpdateAvailable:
                return new NotificationCompat.Action(R.drawable.ic_file_download, context.getString(R.string.notification_action_update), entry.intent);

            case Downloading:
            case Installing:
                return new NotificationCompat.Action(R.drawable.ic_cancel, context.getString(R.string.notification_action_cancel), entry.intent);

            case ReadyToInstall:
                return new NotificationCompat.Action(R.drawable.ic_file_install, context.getString(R.string.notification_action_install), entry.intent);
        }
    }
    return null;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:17,代码来源:NotificationHelper.java

示例2: getServiceNotificationAction

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private static NotificationCompat.Action getServiceNotificationAction(Context context, String action, int iconResId, int titleResId) {
  Intent intent = new Intent(context, WebRtcCallService.class);
  intent.setAction(action);

  PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0);

  return new NotificationCompat.Action(iconResId, context.getString(titleResId), pendingIntent);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:9,代码来源:CallNotificationBuilder.java

示例3: createNotification

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public static void createNotification(Service context) {
    // Create Pending Intents.
    PendingIntent piLaunchMainActivity = getLaunchActivityPI(context);
    PendingIntent piStopService = getStopServicePI(context);

    // Action to stop the service.
    NotificationCompat.Action stopAction =
            new NotificationCompat.Action.Builder(
                            STOP_ACTION_ICON,
                            getNotificationStopActionText(context),
                            piStopService)
                    .build();

    // Create a notification.
    Notification mNotification =
            new NotificationCompat.Builder(context)
                    .setContentTitle(getNotificationTitle(context))
                    .setContentText(getNotificationContent(context))
                    .setSmallIcon(SMALL_ICON)
                    .setContentIntent(piLaunchMainActivity)
                    .addAction(stopAction)
                    .setStyle(new NotificationCompat.BigTextStyle())
                    .build();

    context.startForeground(ONGOING_NOTIFICATION_ID, mNotification);
}
 
开发者ID:r3bl-alliance,项目名称:stay-awake-app,代码行数:27,代码来源:HandleNotifications.java

示例4: addDeleteAllAction

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void addDeleteAllAction(WearableExtender wearableExtender, NotificationData notificationData) {
    int icon = R.drawable.ic_action_delete_dark;
    String title = context.getString(R.string.notification_action_delete_all);

    Account account = notificationData.getAccount();
    ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
    int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
    PendingIntent action = actionCreator.getDeleteAllPendingIntent(account, messageReferences, notificationId);

    NotificationCompat.Action deleteAction = new NotificationCompat.Action.Builder(icon, title, action).build();
    wearableExtender.addAction(deleteAction);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:13,代码来源:WearNotifications.java

示例5: addArchiveAllAction

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void addArchiveAllAction(WearableExtender wearableExtender, NotificationData notificationData) {
    int icon = R.drawable.ic_action_archive_dark;
    String title = context.getString(R.string.notification_action_archive_all);

    Account account = notificationData.getAccount();
    ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences();
    int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
    PendingIntent action = actionCreator.createArchiveAllPendingIntent(account, messageReferences, notificationId);

    NotificationCompat.Action archiveAction = new NotificationCompat.Action.Builder(icon, title, action).build();
    wearableExtender.addAction(archiveAction);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:13,代码来源:WearNotifications.java

示例6: addReplyAction

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void addReplyAction(WearableExtender wearableExtender, NotificationHolder holder) {
    int icon = R.drawable.ic_action_single_message_options_dark;
    String title = context.getString(R.string.notification_action_reply);

    MessageReference messageReference = holder.content.messageReference;
    int notificationId = holder.notificationId;
    PendingIntent action = actionCreator.createReplyPendingIntent(messageReference, notificationId);

    NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(icon, title, action).build();
    wearableExtender.addAction(replyAction);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:12,代码来源:WearNotifications.java

示例7: addMarkAsReadAction

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void addMarkAsReadAction(WearableExtender wearableExtender, NotificationHolder holder) {
    int icon = R.drawable.ic_action_mark_as_read_dark;
    String title = context.getString(R.string.notification_action_mark_as_read);

    MessageReference messageReference = holder.content.messageReference;
    int notificationId = holder.notificationId;
    PendingIntent action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId);

    NotificationCompat.Action markAsReadAction = new NotificationCompat.Action.Builder(icon, title, action).build();
    wearableExtender.addAction(markAsReadAction);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:12,代码来源:WearNotifications.java

示例8: addDeleteAction

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void addDeleteAction(WearableExtender wearableExtender, NotificationHolder holder) {
    int icon = R.drawable.ic_action_delete_dark;
    String title = context.getString(R.string.notification_action_delete);

    MessageReference messageReference = holder.content.messageReference;
    int notificationId = holder.notificationId;
    PendingIntent action = actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId);

    NotificationCompat.Action deleteAction = new NotificationCompat.Action.Builder(icon, title, action).build();
    wearableExtender.addAction(deleteAction);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:12,代码来源:WearNotifications.java

示例9: addArchiveAction

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void addArchiveAction(WearableExtender wearableExtender, NotificationHolder holder) {
    int icon = R.drawable.ic_action_archive_dark;
    String title = context.getString(R.string.notification_action_archive);

    MessageReference messageReference = holder.content.messageReference;
    int notificationId = holder.notificationId;
    PendingIntent action = actionCreator.createArchiveMessagePendingIntent(messageReference, notificationId);

    NotificationCompat.Action archiveAction = new NotificationCompat.Action.Builder(icon, title, action).build();
    wearableExtender.addAction(archiveAction);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:12,代码来源:WearNotifications.java

示例10: MediaNotificationManager

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public MediaNotificationManager(MusicService service) {
    mService = service;

    mNotificationManager =
            (NotificationManager) mService.getSystemService(Context.NOTIFICATION_SERVICE);

    mPlayAction =
            new NotificationCompat.Action(
                    R.drawable.ic_play_arrow_white_24dp,
                    mService.getString(R.string.label_play),
                    MediaButtonReceiver.buildMediaButtonPendingIntent(
                            mService,
                            PlaybackStateCompat.ACTION_PLAY));
    mPauseAction =
            new NotificationCompat.Action(
                    R.drawable.ic_pause_white_24dp,
                    mService.getString(R.string.label_pause),
                    MediaButtonReceiver.buildMediaButtonPendingIntent(
                            mService,
                            PlaybackStateCompat.ACTION_PAUSE));
    mNextAction =
            new NotificationCompat.Action(
                    R.drawable.ic_skip_next_white_24dp,
                    mService.getString(R.string.label_next),
                    MediaButtonReceiver.buildMediaButtonPendingIntent(
                            mService,
                            PlaybackStateCompat.ACTION_SKIP_TO_NEXT));
    mPrevAction =
            new NotificationCompat.Action(
                    R.drawable.ic_skip_previous_white_24dp,
                    mService.getString(R.string.label_previous),
                    MediaButtonReceiver.buildMediaButtonPendingIntent(
                            mService,
                            PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS));

    // Cancel all notifications to handle the case where the Service was killed and
    // restarted by the system.
    mNotificationManager.cancelAll();
}
 
开发者ID:fendoudebb,项目名称:PlayAndroid,代码行数:40,代码来源:MediaNotificationManager.java

示例11: displayUserConfirmNotificationImpl

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void displayUserConfirmNotificationImpl(int accountId, int peerId, int messageId, @NonNull ExchangeMessage message, @NonNull OwnerInfo ownerInfo) {
    if (Utils.hasOreo()) {
        mNotificationManager.createNotificationChannel(AppNotificationChannels.getKeyExchangeChannel(this));
    }

    String targetContentText = getString(R.string.key_exchange_request_content_text, ownerInfo.getUser().getFullName());
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this, AppNotificationChannels.KEY_EXCHANGE_CHANNEL_ID)
            .setSmallIcon(R.drawable.ic_crypt_key_vector)
            .setLargeIcon(ownerInfo.getAvatar())
            .setContentTitle(getString(R.string.key_exchange_request))
            .setContentText(targetContentText)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(targetContentText))
            .setAutoCancel(true);

    Intent intent = KeyExchangeCommitActivity.createIntent(this, accountId, peerId, ownerInfo.getUser(), messageId, message);
    PendingIntent contentIntent = PendingIntent.getActivity(this, messageId, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    builder.setContentIntent(contentIntent);

    Intent apply = createIntentForApply(this, message, accountId, peerId, messageId);
    PendingIntent quickPendingIntent = PendingIntent.getService(this, messageId, apply, PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Action applyAction = new NotificationCompat.Action(R.drawable.check, getString(R.string.apply), quickPendingIntent);

    builder.addAction(applyAction);
    builder.setPriority(NotificationCompat.PRIORITY_HIGH);
    builder.setDefaults(NotificationCompat.DEFAULT_ALL);

    Notification notification = builder.build();
    mNotificationManager.notify(String.valueOf(message.getSessionId()), NOTIFICATION_KEY_EXCHANGE_REQUEST, notification);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:30,代码来源:KeyExchangeService.java

示例12: getActivityNotificationAction

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private static NotificationCompat.Action getActivityNotificationAction(@NonNull Context context, @NonNull String action,
                                                                       @DrawableRes int iconResId, @StringRes int titleResId)
{
  Intent intent = new Intent(context, WebRtcCallActivity.class);
  intent.setAction(action);

  PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);

  return new NotificationCompat.Action(iconResId, context.getString(titleResId), pendingIntent);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:11,代码来源:CallNotificationBuilder.java

示例13: showIncomingCallNotification

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public static void showIncomingCallNotification(Context context, String accountID, int callID) {

        mNotificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);

        Intent activityIntent = new Intent(context, MainActivity.class);
        activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        activityIntent.putExtra(context.getString(R.string.param_call_id), callID);
        activityIntent.putExtra(context.getString(R.string.param_incoming_call), true);

        Intent actionIntent = new Intent(context.getString(R.string.package_name) + "." + context.getString(R.string.notif_incoming_call_intent_action));
        actionIntent.putExtra(context.getString(R.string.param_account_id), accountID);
        actionIntent.putExtra(context.getString(R.string.param_call_id), callID);

        PendingIntent pActivityIntent = PendingIntent.getActivity(context, (int) System.currentTimeMillis(), activityIntent, 0);
        PendingIntent pActionIntent = PendingIntent.getBroadcast(context, (int) System.currentTimeMillis(), actionIntent, 0);

        NotificationCompat.Action acceptCallAction = new NotificationCompat.Action.Builder(R.drawable.ic_call, context.getString(R.string.notif_incoming_call_action_accept), pActionIntent).build();

        Notification n  = new NotificationCompat.Builder(context)
                .setContentTitle(context.getString(R.string.notif_incoming_call_title))
                .setContentText(context.getString(R.string.notif_incoming_call_text))
                .setSmallIcon(R.drawable.ic_call)
                .setContentIntent(pActivityIntent)
                .setAutoCancel(true)
                .addAction(acceptCallAction)
                .build();

        mNotificationManager.notify(mNotifID, n);
    }
 
开发者ID:d0pam1n,项目名称:DoorPhone,代码行数:30,代码来源:NotificationBuilderUtil.java

示例14: showOng

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public void showOng() {
        Intent dialIntent = new Intent(ctx, InCall.class);
        dialIntent.putExtra("incomingnumber", num);
        dialIntent.putExtra("incomingname", n);
        PendingIntent intent1 = PendingIntent.getActivity(ctx, 0, dialIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        Intent dismissReceive = new Intent();
        dismissReceive.setAction(InCallManager.DISMISS);
        PendingIntent intentDismiss = PendingIntent.getBroadcast(ctx, 0, dismissReceive, PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationCompat.Action dismissAction = new NotificationCompat.Action.Builder(R.drawable.ic_call_end_black_24dp, "HANG UP", intentDismiss).build();

        NotificationManager notificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);

        String id = "caller_id_ongoing_channel";
        String name = "caller_id_ongoing_notifications";
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            createChannel(notificationManager, id, name, NotificationManager.IMPORTANCE_DEFAULT);
        }

        NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(ctx, name);
        notifBuilder.setLargeIcon(BitmapFactory.decodeResource(ctx.getResources(), R.mipmap.ic_launcher))
                .setDefaults(Notification.DEFAULT_ALL)
                .setPriority(NotificationCompat.PRIORITY_DEFAULT)
//                .setCategory(Notification.CATEGORY_CALL)
//                .setFullScreenIntent(intent1, true)

                .addAction(dismissAction)

                .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                .setContentTitle(n)
                .setContentText("Ongoing call " + num)
                .setSmallIcon(R.drawable.ic_call_black_24dp)
                .setContentIntent(intent1)

                .setChannelId(id)

                .setOngoing(true)
                .setShowWhen(true)
                .setAutoCancel(false);

//        notifBuilder.flags = android.app.Notification.DEFAULT_LIGHTS | android.app.Notification.FLAG_AUTO_CANCEL;

        notificationManager.notify(766, notifBuilder.build());
    }
 
开发者ID:ceanyd,项目名称:react-native-caller-id-android,代码行数:45,代码来源:CustomNotification.java

示例15: sendNotificationForConversation

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void sendNotificationForConversation(
        int conversationId,
        String sender,
        String message,
        long timestamp) {

    // A pending Intent for reads.
    PendingIntent readPendingIntent = PendingIntent.getBroadcast(
            getApplicationContext(),
            conversationId,
            getMessageReadIntent(conversationId),
            PendingIntent.FLAG_UPDATE_CURRENT);

    // Building a Pending Intent for the reply action to trigger.
    PendingIntent replyIntent = PendingIntent.getBroadcast(
            getApplicationContext(),
            conversationId,
            getMessageReplyIntent(conversationId),
            PendingIntent.FLAG_UPDATE_CURRENT);

    /// TODO: Add the code to create the UnreadConversation.
    /// End create UnreadConversation.

    /// TODO: Add the code to allow in-line reply on Wear 2.0.
    /// End in-line action for Wear 2.0.

    // Add an action to allow replies.
    NotificationCompat.Action replyAction =
            new NotificationCompat.Action.Builder(
                        R.drawable.ic_reply_white_24dp,
                        getString(R.string.reply_action),
                        replyIntent)
                    /// TODO: Add better wear support.
                    .build();


    // Add messages with the MessagingStyle notification.
    NotificationCompat.MessagingStyle messagingStyle =
            new NotificationCompat.MessagingStyle(sender)
                    .addMessage(message, timestamp, sender);

    NotificationCompat.Builder builder =
            new NotificationCompat.Builder(getApplicationContext())
                    .setStyle(messagingStyle)
                    .setDefaults(NotificationCompat.DEFAULT_VIBRATE)
                    .setSmallIcon(R.drawable.notification_icon)
                    .setLargeIcon(BitmapFactory.decodeResource(
                            getApplicationContext().getResources(), R.drawable.android_contact))
                    .setContentText(message)
                    .setWhen(timestamp)
                    .addAction(replyAction)
                    .setContentTitle(sender)
                    .setContentIntent(readPendingIntent)
                    /// TODO: Extend the notification with CarExtender.
                    /// End
                    ;

    Log.d(TAG, "Sending notification " + conversationId + " conversation: " + message);
    NotificationManagerCompat.from(this).notify(conversationId, builder.build());
}
 
开发者ID:googlecodelabs,项目名称:device-messaging,代码行数:61,代码来源:MessagingService.java


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