public class CallContentObserver extends ContentObserver {
private final static String strUriInbox = "content://call_log/calls";
private final static Uri uriCall = Uri.parse(strUriInbox);
private String phoneNum;
private Context context;
public CallContentObserver(Context context, String phoneNum, Handler handler) {
super(handler);
this.context = context;
this.phoneNum = phoneNum;
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
Cursor c = context.getContentResolver().query(uriCall,
new String[] { "_id", "number", "date" }, null, null, null);
if (c != null && c.moveToFirst()) {
String num = c.getString(1);
String id = c.getString(0);
if (num != null &&phoneNum!=null&& num.equals(phoneNum)) {
context.getContentResolver().delete(uriCall, "_id=" + id,
null);
}
// for(int i =0; i < c.getColumnCount(); i++)
// {
// String strColumnName = c.getColumnName(i);
// String strColumnValue = c.getString(i);
// Log.e("i", "i="+i);
// Log.e("strColumnName", "strColumnName="+strColumnName);
// Log.e("strColumnValue", "strColumnValue="+strColumnValue);
// }
c.close();
}
}
}
调用
context.getContentResolver()
.registerContentObserver(
Uri.parse("content://call_log"),
true,
new CallContentObserver(context,
phoneNumber, null));
通过调用ContentObserver,当数据库变化后,才会处理。。此方法可用于如SMS删除,而不用Thread.sleep(不要用Sleep,因为效果非常差,有时无法删除)
短信可用下面的
private final static String strUriInbox = "content://sms/inbox";
private final static Uri uriSms = Uri.parse(strUriInbox);
Cursor c = context.getContentResolver().query(
uriSms,
new String[] { "_id", "thread_id", "address",
"person", "date", "body" }, null, null,
null);
分享到:
相关推荐
android call: call not sent 的log 文件
Android call/calllog 详细流程图
运用Android Studio实现打电话和发短信的功能,对应权限 Manifest.permission.CALL_PHONE和Manifest.permission.SEND_SMS
android Action call 拨打电话 Intent.ACTION.CALL
android:authorities="call_log" android:syncable="false" android:multiprocess="false" android:readPermission="android.permission.READ_CONTACTS" android:writePermission="android.permission.WRITE_...
Andorid调用FFMPEG,并保存 rtps 为mp4文件。应该挺实用的把。
* Integrate your application with SMS and MMS messages - enable users to send SMS and MMS messages to your site, process them, and send SMS and MMS messages back to your users too; set up your own ...
Android_4.4_Telephony_CallState_Analysis
android开发,打印调用栈 ,callstack.cpp,android开发,打印调用栈,android开发,打印调用栈
1.1 GSM Network Architecture and Principle of the SMS Procedure 1 1.2 Implementation of SMS Services 3 1.2.1 SMS-MO Implementation 3 1.2.2 The SMS-MT Implementation 6 1.2.3 Sending Commands to the ...
Android下各语言加callStack打印信息的示例 包括C语言, C++,Java和Kernel Space。
android.permission.BROADCAST_SMS,当收到短信时触发一个广播 连续广播 android.permission.BROADCAST_STICKY,允许一个程序收到广播后快速收到下一个广播 WAP PUSH广播 android.permission.BROADCAST_WAP_...
这个惊人的应用程序将帮助您通过单击阻止不需要的电话和短信。 您可以查看已被您屏蔽的通话记录。
Delphi XE5 Android ZXing Call Demo
本代码合集包括10个源代码:(1)call_listener利用广播接收器监听来电、去电,拨打电话或接听电话时,屏幕下方显示信息提示框。 (2)call_aidl用程序控制接听和挂断动作。利用此技术可以实现来电黑名单。 (3)...
android上层应用层call的详细介绍
EndCall.zip android挂断电话的例子
NULL 博文链接:https://lihao312.iteye.com/blog/2094576