How to send and receive data SMS messages

I know this is 1 year old at time of my response, but I thought it could still help someone. Receiving: Bundle bundle = intent.getExtras(); String recMsgString = “”; String fromAddress = “”; SmsMessage recMsg = null; byte[] data = null; if (bundle != null) { //—retrieve the SMS message received— Object[] pdus = (Object[]) … Read more

Deleting Android SMS programmatically

Actually, the code in my post is 100% correct. The problem was that Android needs some time to store the SMS upon receiving it. So the solution is to just add a handler and delay the delete request for 1 or 2 seconds. This actually solved the whole issue. EDIT (thanks to Maksim Dmitriev): Please … Read more

Broadcast Receiver within a Service

as your service is already setup, simply add a broadcast receiver in your service: private final BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if(action.equals(“android.provider.Telephony.SMS_RECEIVED”)){ //action for sms received } else if(action.equals(android.telephony.TelephonyManager.ACTION_PHONE_STATE_CHANGED)){ //action for phone state changed } } }; in your service’s onCreate do … Read more

How to pre-populate the sms body text via an html link

It turns out this is 100% possible, though a little hacky. If you want it to work on Android you need to use this format: <a href=”https://stackoverflow.com/questions/6480462/sms:/* phone number here */?body=/* body text here */”>Link</a> If you want it to work on iOS, you need this: <a href=”https://stackoverflow.com/questions/6480462/sms:/* phone number here */;body=/* body text here … Read more

How to send a SMS using SMSmanager in Dual SIM mobile?

I use this way to manage which sim to use for sending SMS even long message .. Its working on my dual sim phone Lenovo A319 (4.4.3), no need for root. its built on reflection. import android.app.PendingIntent; import android.content.Context; import android.os.Build; import android.os.IBinder; import android.util.Log; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; /** * … Read more

How to delete an SMS from the inbox in Android programmatically?

“As of Android 1.6, incoming SMS message broadcasts (android.provider.Telephony.SMS_RECEIVED) are delivered as an “ordered broadcast” — meaning that you can tell the system which components should receive the broadcast first.” This means that you can intercept incoming message and abort broadcasting of it further on. In your AndroidManifest.xml file, make sure to have priority set … Read more

launch sms application with an intent

To start launch the sms activity all you need is this: Intent sendIntent = new Intent(Intent.ACTION_VIEW); sendIntent.setData(Uri.parse(“sms:”)); You can add extras to populate your own message and such like this sendIntent.putExtra(“sms_body”, x); then just startActivity with the intent. startActivity(sendIntent);