Android development, video group chat trigger SMS exception

Source: Internet
Author: User

I am developing a program that sends a message to reply after receiving the message (Auto-reply), when my phone launches the group chat program, my program does not send the message successfully, so I use the following code to solve the problem.

<intent-filter android:priority= ">"
<action android:name= "Android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>

After the message was sent, I specifically recorded the SMS log, but now the SMS receive priority higher than group chat, sent messages are written to the user's SMS records received messages, he should show the following log:

Response Message
Received Message-this is what triggered the response

But now he's showing the wrong log, as follows

Received message-triggers Response

Response Message

I feel my program is affected by the group chat program, disrupting my program, and now I don't know what to do with it.

Here is my code:

Context.getcontentresolver (). Registercontentobserver (Uri.parse ("Content://sms"), true, Smsobserver); And this class:private class Smsobserver extends contentobserver{public    smsobserver ()    {        super (NULL);    }     @Override Public    boolean deliverselfnotifications () {        return true;    }     @Override public    void OnChange (Boolean selfchange) {        super.onchange (selfchange);        if (!selfchange)            //sendresponse        context.getcontentresolver (). Unregistercontentobserver (this);    }     @Override public    void OnChange (Boolean selfchange, Uri uri) {        super.onchange (Selfchange, URI);        if (!selfchange)            //sendresponse        context.getcontentresolver (). Unregistercontentobserver (this);}    }

Processing methods

Try using Contentobserver to listen to the message when the group chat program is sent, or test other phones to see if the same problem occurs

Can be tested with the following code

12345678 context.getcontentresolver (). Registercontentobserver (Uri.parse (" content://sms "), true or cursor = Context.getcontentresolver (). Query (Uri.parse (" Content://sms/inbox "), &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; new string[" {sms_id, sms_address, sms_read}, &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; " read = 0 ", &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; null , &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; null cursor.registerContentObserver(myContentObserver);

But I can't use non-cursor version, SMS/inbox for some reason. The downside of a cursor-based version is that it seems to need to be kept open, so you have to be sure to close it later.
Also, the version is called when the read state is changed.


Original address: http://www.itmmd.com/201411/141.html
This article by Meng Meng's IT person to organize the release, reprint must indicate the source.


Android development, video group chat trigger SMS exception

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.