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


Java MessageSender.send方法代码示例

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


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

示例1: doInBackground

import org.thoughtcrime.securesms.sms.MessageSender; //导入方法依赖的package包/类
@Override
protected Void doInBackground(String... numbers) {
  final Context context = getContext();
  if (context == null) return null;

  for (String number : numbers) {
    Recipients recipients = RecipientFactory.getRecipientsFromString(context, number, false);

    if (recipients.getPrimaryRecipient() != null) {
      Optional<RecipientsPreferences> preferences    = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipients.getIds());
      int                             subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;

      MessageSender.send(context, masterSecret, new OutgoingTextMessage(recipients, message, subscriptionId), -1L, true);

      if (recipients.getPrimaryRecipient().getContactUri() != null) {
        DatabaseFactory.getRecipientPreferenceDatabase(context).setSeenInviteReminder(recipients, true);
      }
    }
  }
  return null;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:22,代码来源:InviteActivity.java

示例2: doInBackground

import org.thoughtcrime.securesms.sms.MessageSender; //导入方法依赖的package包/类
@Override
protected Void doInBackground(String... numbers) {
  final Context context = getContext();
  if (context == null) return null;

  for (String number : numbers) {
    Recipients recipients = RecipientFactory.getRecipientsFromString(context, number, false);

    if (recipients.getPrimaryRecipient() != null) {
      Optional<RecipientsPreferences> preferences    = DatabaseFactory.getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipients.getIds());
      int                             subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;

      MessageSender.send(context, masterSecret, new OutgoingTextMessage(recipients, message, subscriptionId), -1L, true, null);

      if (recipients.getPrimaryRecipient().getContactUri() != null) {
        DatabaseFactory.getRecipientPreferenceDatabase(context).setSeenInviteReminder(recipients, true);
      }
    }
  }
  return null;
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:22,代码来源:InviteActivity.java

示例3: handlePushOperation

import org.thoughtcrime.securesms.sms.MessageSender; //导入方法依赖的package包/类
private Pair<Long, Recipients> handlePushOperation(byte[] groupId, String groupName, byte[] avatar,
                                                   Set<String> e164numbers)
    throws InvalidNumberException
{

  try {
    String     groupRecipientId = GroupUtil.getEncodedId(groupId);
    Recipients groupRecipient   = RecipientFactory.getRecipientsFromString(this, groupRecipientId, false);

    GroupContext context = GroupContext.newBuilder()
                                       .setId(ByteString.copyFrom(groupId))
                                       .setType(GroupContext.Type.UPDATE)
                                       .setName(groupName)
                                       .addAllMembers(e164numbers)
                                       .build();

    OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(this, groupRecipient, context, avatar);
    long                      threadId        = MessageSender.send(this, masterSecret, outgoingMessage, -1, false);

    return new Pair<>(threadId, groupRecipient);
  } catch (RecipientFormattingException e) {
    throw new AssertionError(e);
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:25,代码来源:GroupCreateActivity.java

示例4: initiateKeyExchange

import org.thoughtcrime.securesms.sms.MessageSender; //导入方法依赖的package包/类
private static void initiateKeyExchange(Context context, MasterSecret masterSecret, Recipient recipient) {
  SessionStore      sessionStore      = new TextSecureSessionStore(context, masterSecret);
  PreKeyStore       preKeyStore       = new TextSecurePreKeyStore(context, masterSecret);
  SignedPreKeyStore signedPreKeyStore = new TextSecurePreKeyStore(context, masterSecret);
  IdentityKeyStore  identityKeyStore  = new TextSecureIdentityKeyStore(context, masterSecret);

  SessionBuilder    sessionBuilder    = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
                                                           identityKeyStore, recipient.getRecipientId(),
                                                           PushAddress.DEFAULT_DEVICE_ID);

  KeyExchangeMessage         keyExchangeMessage = sessionBuilder.process();
  String                     serializedMessage  = Base64.encodeBytesWithoutPadding(keyExchangeMessage.serialize());
  OutgoingKeyExchangeMessage textMessage        = new OutgoingKeyExchangeMessage(recipient, serializedMessage);

  MessageSender.send(context, masterSecret, textMessage, -1, false);
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:17,代码来源:KeyExchangeInitiator.java

示例5: sendGroupUpdate

import org.thoughtcrime.securesms.sms.MessageSender; //导入方法依赖的package包/类
private static GroupActionResult sendGroupUpdate(@NonNull  Context      context,
                                                 @NonNull  MasterSecret masterSecret,
                                                 @NonNull  byte[]       groupId,
                                                 @NonNull  Set<String>  e164numbers,
                                                 @NonNull  String       ownerE164number,
                                                 @NonNull  Set<String>  adminE164numbers,
                                                 @Nullable String       groupName,
                                                 @Nullable byte[]       avatar,
                                                 @Nullable Recipients   destRecipients)
{
  Attachment avatarAttachment = null;
  String     groupRecipientId = GroupUtil.getEncodedId(groupId);
  Recipients groupRecipient   = RecipientFactory.getRecipientsFromString(context, groupRecipientId, false);

  GroupContext.Builder groupContextBuilder = GroupContext.newBuilder()
                                                         .setId(ByteString.copyFrom(groupId))
                                                         .setType(GroupContext.Type.UPDATE)
                                                         .addAllMembers(e164numbers)
                                                         .addAllAdmins(adminE164numbers);
  if (groupName != null) groupContextBuilder.setName(groupName);

  if(ownerE164number != null) {
    groupContextBuilder.setOwner(ownerE164number);
  }

  GroupContext groupContext = groupContextBuilder.build();

  if (avatar != null) {
    Uri avatarUri = SingleUseBlobProvider.getInstance().createUri(avatar);
    avatarAttachment = new UriAttachment(avatarUri, ContentType.IMAGE_PNG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, avatar.length);
  }

  OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(groupRecipient, groupContext, avatarAttachment, System.currentTimeMillis(), 0);
  long                      threadId        = MessageSender.send(context, masterSecret, outgoingMessage, -1, false, destRecipients);

  return new GroupActionResult(groupRecipient, threadId);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:38,代码来源:GroupManager.java

示例6: onHandleIntent

import org.thoughtcrime.securesms.sms.MessageSender; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent, @Nullable MasterSecret masterSecret) {
  if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(intent.getAction())) {
    Log.w(TAG, "Received unknown intent: " + intent.getAction());
    return;
  }

  if (masterSecret == null) {
    Log.w(TAG, "Got quick response request when locked...");
    Toast.makeText(this, R.string.QuickResponseService_quick_response_unavailable_when_Signal_is_locked, Toast.LENGTH_LONG).show();
    return;
  }

  try {
    Rfc5724Uri uri        = new Rfc5724Uri(intent.getDataString());
    String     content    = intent.getStringExtra(Intent.EXTRA_TEXT);
    String     numbers    = uri.getPath();
    if(numbers.contains("%")){
      numbers = URLDecoder.decode(numbers);
    }

    Recipients                      recipients     = RecipientFactory.getRecipientsFromString(this, numbers, false);
    Optional<RecipientsPreferences> preferences    = DatabaseFactory.getRecipientPreferenceDatabase(this).getRecipientsPreferences(recipients.getIds());
    int                             subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;
    long                            expiresIn      = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0;

    if (!TextUtils.isEmpty(content)) {
      if (recipients.isSingleRecipient()) {
        MessageSender.send(this, masterSecret, new OutgoingTextMessage(recipients, content, expiresIn, subscriptionId), -1, false);
      } else {
        MessageSender.send(this, masterSecret, new OutgoingMediaMessage(recipients, new SlideDeck(), content, System.currentTimeMillis(),
                                                                        subscriptionId, expiresIn, ThreadDatabase.DistributionTypes.DEFAULT), -1, false);
      }
    }
  } catch (URISyntaxException e) {
    Toast.makeText(this, R.string.QuickResponseService_problem_sending_message, Toast.LENGTH_LONG).show();
    Log.w(TAG, e);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:40,代码来源:QuickResponseService.java

示例7: sendGroupUpdate

import org.thoughtcrime.securesms.sms.MessageSender; //导入方法依赖的package包/类
private static GroupActionResult sendGroupUpdate(@NonNull  Context      context,
                                                 @NonNull  MasterSecret masterSecret,
                                                 @NonNull  byte[]       groupId,
                                                 @NonNull  Set<String>  e164numbers,
                                                 @Nullable String       groupName,
                                                 @Nullable byte[]       avatar)
{
  Attachment avatarAttachment = null;
  String     groupRecipientId = GroupUtil.getEncodedId(groupId);
  Recipients groupRecipient   = RecipientFactory.getRecipientsFromString(context, groupRecipientId, false);

  GroupContext.Builder groupContextBuilder = GroupContext.newBuilder()
                                                         .setId(ByteString.copyFrom(groupId))
                                                         .setType(GroupContext.Type.UPDATE)
                                                         .addAllMembers(e164numbers);
  if (groupName != null) groupContextBuilder.setName(groupName);
  GroupContext groupContext = groupContextBuilder.build();

  if (avatar != null) {
    Uri avatarUri = SingleUseBlobProvider.getInstance().createUri(avatar);
    avatarAttachment = new UriAttachment(avatarUri, MediaUtil.IMAGE_PNG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, avatar.length, null, false);
  }

  OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(groupRecipient, groupContext, avatarAttachment, System.currentTimeMillis(), 0);
  long                      threadId        = MessageSender.send(context, masterSecret, outgoingMessage, -1, false, null);

  return new GroupActionResult(groupRecipient, threadId);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:29,代码来源:GroupManager.java

示例8: onHandleIntent

import org.thoughtcrime.securesms.sms.MessageSender; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent, @Nullable MasterSecret masterSecret) {
  if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(intent.getAction())) {
    Log.w(TAG, "Received unknown intent: " + intent.getAction());
    return;
  }

  if (masterSecret == null) {
    Log.w(TAG, "Got quick response request when locked...");
    Toast.makeText(this, R.string.QuickResponseService_quick_response_unavailable_when_Signal_is_locked, Toast.LENGTH_LONG).show();
    return;
  }

  try {
    Rfc5724Uri uri        = new Rfc5724Uri(intent.getDataString());
    String     content    = intent.getStringExtra(Intent.EXTRA_TEXT);
    String     numbers    = uri.getPath();
    if(numbers.contains("%")){
      numbers = URLDecoder.decode(numbers);
    }

    Recipients                      recipients     = RecipientFactory.getRecipientsFromString(this, numbers, false);
    Optional<RecipientsPreferences> preferences    = DatabaseFactory.getRecipientPreferenceDatabase(this).getRecipientsPreferences(recipients.getIds());
    int                             subscriptionId = preferences.isPresent() ? preferences.get().getDefaultSubscriptionId().or(-1) : -1;
    long                            expiresIn      = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0;

    if (!TextUtils.isEmpty(content)) {
      if (recipients.isSingleRecipient()) {
        MessageSender.send(this, masterSecret, new OutgoingTextMessage(recipients, content, expiresIn, subscriptionId), -1, false, null);
      } else {
        MessageSender.send(this, masterSecret, new OutgoingMediaMessage(recipients, new SlideDeck(), content, System.currentTimeMillis(),
                                                                        subscriptionId, expiresIn, ThreadDatabase.DistributionTypes.DEFAULT), -1, false, null);
      }
    }
  } catch (URISyntaxException e) {
    Toast.makeText(this, R.string.QuickResponseService_problem_sending_message, Toast.LENGTH_LONG).show();
    Log.w(TAG, e);
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:40,代码来源:QuickResponseService.java


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