コード例 #1
0
  public void notifyForBox(
      List<Message> messages, String chatboxName, int chatboxID, boolean withSound) {
    if (messages.size() == 0) return;

    StatisticTracker.trackReceiveNotification(StatisticTracker.NOTIFICATION_CHATBOX_TYPE);
    Intent i = new Intent(mContext, ChatWing.instance(mContext).getMainActivityClass());
    i.setAction(CommunicationActivity.ACTION_OPEN_CHATBOX);
    i.putExtra(CommunicationActivity.CHATBOX_ID, chatboxID);
    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

    doNotify(i, chatboxName, messages, chatboxID, withSound);
  }
コード例 #2
0
  public void notifyForBox(
      List<Message> messages, String conversationID, User targetUser, boolean withSound) {
    // Extra filter here to make sure user won't receive messages not sending to them.
    if (targetUser != null && !targetUser.equals(mUserManager.getCurrentUser()))
      return; // Not send to me, so nothing right now
    if (messages.size() == 0) return;
    StatisticTracker.trackReceiveNotification(StatisticTracker.NOTIFICATION_CONVERSATION_TYPE);

    Intent i = new Intent(mContext, ChatWing.instance(mContext).getMainActivityClass());
    i.setAction(CommunicationActivity.ACTION_OPEN_CONVERSATION);
    i.putExtra(CommunicationActivity.CONVERSATION_ID, conversationID);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

    LogUtils.v("Check user name " + messages.get(0).getUserName());
    doNotify(i, messages.get(0).getUserName(), messages, conversationID.hashCode(), withSound);
  }
コード例 #3
0
  public void showBroadCastMessage(String name, String message) {
    StatisticTracker.trackReceiveNotification(StatisticTracker.NOTIFICATION_BROADCAST_TYPE);

    PendingIntent contentIntent =
        PendingIntent.getActivity(
            mContext,
            0,
            new Intent(mContext, ChatWing.instance(mContext).getMainActivityClass()),
            PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder builder =
        new NotificationCompat.Builder(mContext)
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle(mContext.getString(R.string.broadcast_tag) + " to " + name + " ")
            .setTicker(message)
            .setContentText(message);

    builder.setContentIntent(contentIntent);
    builder.setAutoCancel(true);
    mNotificationManager.notify(message.hashCode(), builder.build());
  }