문제

I am trying to create a ContentObserver that will inform me when an SMS is sent from my device. When I use the following my onChange() gets called:

public static final Uri uriSMS = Uri.parse("content://sms");

However, when I try to limit it to just sent SMS messages using this:

public static final Uri uriSMS = Uri.parse("content://sms/sent");

it does not work; the onChange() method simply doesn't get called. Can anyone help me troubleshoot this?

도움이 되었습니까?

해결책

Use

public static final Uri uriSMS = Uri.parse("content://sms");

and check the type of the cursor

Here is an example code.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top