失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > android 接收来电广播 android中未接来电的广播接收器

android 接收来电广播 android中未接来电的广播接收器

时间:2023-07-30 17:54:10

相关推荐

android 接收来电广播 android中未接来电的广播接收器

Joe..

11

您需要使用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);

如果觉得《android 接收来电广播 android中未接来电的广播接收器》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。