How to get Delivery Report for sent text message?
try this link,
SMS Delivery Report in Android
class deliverReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), sms_delivered,
Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(getBaseContext(), sms_not_delivered,
Toast.LENGTH_SHORT).show();
break;
}
}
}
don't forgot to add these permissions in manifest
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
Android SmsManger Delivery report
Create your delivered pending intent with an extra that you will use to identify the message sent.
Intent deliveredIntent = new Intent(DELIVERED + id);
deliveredIntent.putExtra("id", id); // Add some unique id as an extra
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
deliveredIntent, 0);
registerReceiver(new BroadcastReceiver()
{
@Override
public void onReceive(Context arg0, Intent arg1)
{
lonng messageID = arg1.getLongExtra("id", -1L);
if(id!=-1)
{
// you got your sms delivered with the id
}
}
}, new IntentFilter(DELIVERED+id));
Related Topics
Don't Keep Activities - What Is It For
How to Add Button in Actionbar(Android)
How to Add New Activity to Existing Project in Android Studio
Android: How Does Gridview Auto_Fit Find the Number of Columns
Android: Change Default Home Application
Android Studio 3.1 Cannot Resolve Symbol (Themes, Widget, Attr, etc.)
How to Use Recyclerview.Scrolltoposition() to Move the Position to the Top of Current View
Getting Results of Nearby Places from User's Location Using Google Maps API in Android
Eclipse Indigo - Cannot Install Android Adt Plugin
Justify Text in an Android App Using a Webview But Presenting a Textview-Like Interface
React Native Adb Reverse Enoent
Importing Jar Libraries into Android-Studio
Android Open Camera from Button
Retrieve Large Blob from Android SQLite Database
How to Share Photo with Caption via Android Share Intent on Facebook