Observe sms sending app in emulator

六眼飞鱼酱① 提交于 2019-12-23 17:18:39

问题


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);


来源:https://stackoverflow.com/questions/8991339/observe-sms-sending-app-in-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!