0

I am working on the message sending and receiving , i got many answers for message receiving via broadcast receiver , But there is no solution for message sent .

<receiver
            android:name="com.test.services.MessageReciver"
            android:enabled="true"
            android:permission="android.permission.BROADCAST_SMS" >
            <intent-filter>

                <action android:name="android.provider.Telephony.SMS_DELIVER" />
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />

            </intent-filter>
        </receiver>



public static final String ACTION_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
    public static final String ACTION_SENT = "android.provider.Telephony.SMS_DELIVER";

    Context context;

    @Override
    public void onReceive(Context context, Intent intent) {

// this section works only when message received on in case of sent
}

But the broadcast receiver work only for message received not for message sent.

Amit Sharma
  • 926
  • 2
  • 10
  • 35

2 Answers2

1

You should put PendingIntent for SMS Sent and Delivery. Please refer the below Syntax:

sendTextMessage (String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)

sentIntent and deliveryIntent can be used as a broadcast action and you can fulfil your desired task.

Ishant
  • 148
  • 7
  • Thanks But i am sending the message from default message application . I want to detect that message which is sending currnlty from device default application not from the custom application. – Amit Sharma Oct 07 '15 at 08:14
  • OP doesn't want to send an SMS, he wants to detect when a SMS is sent – Tim Oct 07 '15 at 08:21
1

The problem here is that they are in fact both receive actions, the difference in them being that one is only delivered to the default sms app, while the other is delivered to all sms apps.

public static final String SMS_DELIVER_ACTION

Broadcast Action: A new text-based SMS message has been received by the device. This intent will only be delivered to the default sms app.

Constant Value: "android.provider.Telephony.SMS_DELIVER"


public static final String SMS_RECEIVED_ACTION

Broadcast Action: A new text-based SMS message has been received by the device. This intent will be delivered to all registered receivers as a notification.

Constant Value: "android.provider.Telephony.SMS_RECEIVED"

There is no action that is broadcasted when a SMS is sent.

For receiving sent SMS broadcasts, check

Community
  • 1
  • 1
Tim
  • 41,901
  • 18
  • 127
  • 145