Observe sms sending app in emulator

2019-07-02 21:10发布

问题:

Is there a way to read outgoing sms from the emulator?

In the logcat I see this message:

D/SmsStorageMonitor(  738): SMS send size=0 time=1327423357467

Is there a way to get the receiver and the content?

The outgoing sms seems not to be saved in the emulator. That means that the messenger app shows me no sms.

回答1:

Yes just create one service in your app and observe all outgoing sms just refer below code.

public class SMSObserver extends BroadcastReceiver 
{
    static final String ACTION ="android.provider.Telephony.SMS_SENT";

    @Override 
    public void onReceive(Context context, Intent intent) 
    { 
        if (intent.getAction().equals(ACTION)) 
        {
                 //your action code here
        }            
    }


回答2:

If you're using your local database to store the outgoing messages while sending from your application, it is possible.



回答3:

Try to observe the content resolver like following code:

ContentResolver contentResolver = getContentResolver();
contentResolver.registerContentObserver("content://sms", true, yourObserver);