Android development, text message exception caused by video group chat, android text message

Source: Internet
Author: User

Android development, text message exception caused by video group chat, android text message

I am developing a program (automatic reply) for sending a text message after receiving the message. When my mobile phone starts the group chat program, my program did not send the message successfully, so I used the following code to solve this problem.

<Intent-filter android: priority = "500">
<Action android: name = "android. provider. Telephony. SMS_RECEIVED"/>
</Intent-filter>

After the message is sent, I specifically recorded the SMS log, but now the SMS receiving priority is higher than the group chat, The sent message is written to the user's SMS record after receiving the message, the following logs should be displayed:

Response Message
Received Message-this is what triggered the response

However, the log displayed by him is incorrect, as shown below:

Received Message-triggers response

Response Message

I feel that my program has been affected by the group chat program and disrupted my program. Now I don't know how to deal with it.

The following 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);    }}

Solution

Try to use ContentObserver to listen to the content when the group chat program sends text messages, or test other mobile phones to see if the same problem occurs.

The following code can be used for testing:

12345678 context.getContentResolver().registerContentObserver(Uri.parse("content://sms"),true, myContentObserver);Orcursor = context.getContentResolver().query(Uri.parse("content://sms/inbox"),            newString[] { SMS_ID, SMS_ADDRESS, SMS_READ },            "read = 0",            null,            null);cursor.registerContentObserver(myContentObserver);

However, I cannot use a non-cursor version for some reasons in the text message/inbox. The disadvantage of the cursor-based version is that it seems to need to be kept open, so you must make sure to close it later.
In addition, whether the version is called when the read status changes.


Address: http://www.itmmd.com/201411/141.html
This article is organized and published by Meng IT personnel. The reprinted article must indicate the source.


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.