Code example for SmsMessage: Receiving Text Messages (SMS)

Methods: getMessageBodygetOriginatingAddress

0
		SmsMessage smsMessage = smsMessages[0];
		this.handleSms(context, smsMessage);
	} 
	 
	public void handleSms(Context context, SmsMessage smsMessage) { 
		String sender = smsMessage.getOriginatingAddress();
		String body = smsMessage.getMessageBody();	
		Cursor contact = getContactForNumber(context, sender);
		if (contact != null) {
			String contactId = contact.getString(0);
			String fullName = contact.getString(1);
			//Toast.makeText(context, "Received SMS from Responder with ID " + contactId+ ": " + body, Toast.LENGTH_LONG).show(); 
			if (isResponder(smsMessage)) {
				handleResponderSms(context, contactId, fullName, body);
			} else { 
				// Not interested 
			} 
		} 
	} 
	 
Stop searching for code, let great code find you!  Add Codota to your java IDE