Android SmsManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SmsManager class.

This code example shows how to use the following methods: sendTextMessage
	} 
	 
	@Test 
	public void shouldStoreLastSentTextMessageParameters() { 
		 
		smsManager.sendTextMessage(testDestinationAddress, testScAddress, testText, null, null);
		 
		ShadowSmsManager.TextSmsParams lastParams = shadowSmsManager.getLastSentTextMessageParams();
		 
		Assert.assertEquals(testDestinationAddress, lastParams.getDestinationAddress());
		Assert.assertEquals(testScAddress, lastParams.getScAddress());
		Assert.assertEquals(testText, lastParams.getText());
	} 
 
    @Test 
    public void shouldClearLastSentTestMessageParameters() { 
        smsManager.sendTextMessage(testDestinationAddress, testScAddress, testText, null, null);
        shadowSmsManager.clearLastSentTextMessageParams();
        Assert.assertNull(shadowSmsManager.getLastSentTextMessageParams());
    } 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: divideMessage, sendMultipartTextMessage
		 
		if (mSMSManager == null) {
			return (false); 
		} 
 
		mFragmentList = mSMSManager.divideMessage(aMessageText);
		int fragmentCount = mFragmentList.size();
		if (fragmentCount > 1) {
			Log.d(TAG, "Sending " + fragmentCount + " parts");
			mSMSManager.sendMultipartTextMessage(aDestinationAddress, 
					mServiceCentreAddr,
					mFragmentList, null, null);
		} else { 
			Log.d(TAG, "Sendine one part");
			mSMSManager.sendTextMessage(aDestinationAddress, 
					mServiceCentreAddr,
					aMessageText, null, null);
		} 
 
		return true; 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: sendTextMessage
				Toast.makeText(this,"Message is longer then allowed in SMS",Toast.LENGTH_LONG).show();
			} else{ 
				PendingIntent piSend = PendingIntent.getBroadcast(this, 0, new Intent(SMS_SENT),0);
				PendingIntent piDelivered = PendingIntent.getBroadcast(this, 0, new Intent(SMS_DELIVERED), 0);
 
				manager.sendTextMessage(number, null, message, piSend, piDelivered);
				etMessage.setText("");
			} 
		} 
	} 
 
	@Override 
	protected void onResume() { 
		registerReceiver(outgoingSMSBR, new IntentFilter(SMS_SENT));
 
		registerReceiver(deliverSMSBR, new IntentFilter(SMS_DELIVERED));
 
		super.onResume(); 
	} 
 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: divideMessage, sendTextMessage, getClass
		aclass[8] = Integer.TYPE;
 
		Method method;
 
		try { 
			method = smsManager.getClass().getMethod("sendMultipartTextMessage", aclass);
 
			Object aobj[] = new Object[9];
			aobj[0] = phoneNumber;
			aobj[1] = null;
			aobj[2] = smsManager.divideMessage(message);
			aobj[3] = sendIntents;
			aobj[4] = deIntents;
			aobj[5] = Boolean.valueOf(false);
			aobj[6] = Integer.valueOf(0);
			aobj[7] = Integer.valueOf(0);
			aobj[8] = Integer.valueOf(0);
 
			method.invoke(smsManager, aobj);
 

5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: divideMessage, sendTextMessage, getClass
		aclass[8] = Integer.TYPE;
 
		Method method;
 
		try { 
			method = smsManager.getClass().getMethod("sendMultipartTextMessage", aclass);
 
			Object aobj[] = new Object[9];
			aobj[0] = phoneNumber;
			aobj[1] = null;
			aobj[2] = smsManager.divideMessage(message);
			aobj[3] = sendIntents;
			aobj[4] = deIntents;
			aobj[5] = Boolean.valueOf(false);
			aobj[6] = Integer.valueOf(0);
			aobj[7] = Integer.valueOf(0);
			aobj[8] = Integer.valueOf(0);
 
			method.invoke(smsManager, aobj);
 

5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: divideMessage
This code example shows how to use the following methods: sendTextMessage
 
        try { 
            // TODO: Display a toast or something when this succeeds? 
            // Note: This does not store the message in the sent folder. 
            // TODO: Optionally store messages in sent folder? 
            manager.sendTextMessage(destinationAddress, null, text, null, null);
        } catch (NullPointerException e) {
            // Seems to occur when SMS can't be sent (e.g. no service?) 
            e.printStackTrace();
        } 
    } 
 
 
    // @Hide 
    public static FeatureConfig fromArray(Context context, String[] theArray) {
        return new SmsFeature(context, theArray[SMS_ARRAY_OFFSET_ACTION], theArray[SMS_ARRAY_OFFSET_CONTACT],
                theArray[SMS_ARRAY_OFFSET_TEXT]);
    } 
 
} 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: sendTextMessage
 
  @Rpc(description = "Sends an SMS.") 
  public void smsSend( 
      @RpcParameter(name = "destinationAddress", description = "typically a phone number") String destinationAddress,
      @RpcParameter(name = "text") String text) {
    mSms.sendTextMessage(destinationAddress, null, text, null, null);
  } 
 
  @Rpc(description = "Returns the number of messages.") 
  public Integer smsGetMessageCount(@RpcParameter(name = "unreadOnly") Boolean unreadOnly,
      @RpcParameter(name = "folder") @RpcDefault("inbox") String folder) {
    Uri uri = buildFolderUri(folder);
    Integer result = 0;
    String selection = buildSelectionClause(unreadOnly);
    Cursor cursor = mContentResolver.query(uri, null, selection, null, null);
    if (cursor != null) {
      result = cursor.getCount();
      cursor.close();
    } else { 
      result = 0;
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: sendTextMessage
        a = SmsManager.getDefault();
    } 
 
    public final boolean a(String s, String s1, PendingIntent pendingintent)
    { 
        a.sendTextMessage(s, null, s1, pendingintent, null);
        return true; 
    } 
 
    private SmsManager a;
} 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: sendTextMessage
  /** 
   * Send a text message 
   */ 
   
  public void SendMessage() { 
    smsManager.sendTextMessage(phoneNumber, null, message, null, null);
  } 
 
  /** 
   * Event that's raised when a new text message is received by the phone. 
   * @param number the phone number that the text message was sent from. 
   * @param messageText the text of the message. 
   */ 
   
  public void MessageReceived(String number, String messageText) {
    // TODO(user): maybe we should unregister and re-register the SmsReceiver based on the 
    // receivingEnabled setting rather than just checking here. 
    if (receivingEnabled) {
      Log.d("Simple", "MessageReceived");
      EventDispatcher.dispatchEvent(this, "MessageReceived", number, messageText);
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android SmsManager Questions & Answers:

See Code Examples for Android SmsManager Methods: