有谁知道未接电话的意图是什么。实际上我想在我的应用程序中发送未接来电和来电的短信。
10683 次
2 回答
12
您需要使用 ContentObserver
public class MissedCallsContentObserver extends ContentObserver
{
public MissedCallsContentObserver()
{
super(null);
}
@Override
public void onChange(boolean selfChange)
{
Cursor cursor = getContentResolver().query(
Calls.CONTENT_URI,
null,
Calls.TYPE + " = ? AND " + Calls.NEW + " = ?",
new String[] { Integer.toString(Calls.MISSED_TYPE), "1" },
Calls.DATE + " DESC ");
//this is the number of missed calls
//for your case you may need to track this number
//so that you can figure out when it changes
cursor.getCount();
cursor.close();
}
}
在您的应用程序中,您只需执行以下操作:
MissedCallsContentObserver mcco = new MissedCallsContentObserver();
getApplicationContext().getContentResolver().registerContentObserver(Calls.CONTENT_URI, true, mcco);
于 2011-01-13T19:59:04.593 回答
10
AFAIK 没有针对未接来电的特定广播。
您可以观看ACTION_PHONE_STATE_CHANGED
广播,等到手机从EXTRA_STATE_RINGING
切换到EXTRA_STATE_IDLE
,然后尝试检查CallLog
内容提供商以查看是否未接来电。我没有尝试过这种技术,但它可能会奏效。
于 2010-09-08T10:19:20.090 回答