我一直试图弄清楚如何制定我的某个项目的要求。要求是获取有关电话的信息:
到目前为止我发现的并不是那么多。下一个链接
http://developer.android.com/reference/android/telephony/PhoneStateListener.html
谈谈创建一个听众来接听来电号码。
任何人都可以帮助我完成剩下的功能吗?在哪里获取电话的传出信息?有没有办法知道什么时候电话结束,原因是什么?
提前谢谢你,
答案 0 :(得分:2)
private void getCallLogDetail( Context context ) {
String[] projection = new String[] {
BaseColumns._ID,
CallLog.Calls.NUMBER,
CallLog.Calls.TYPE,
CallLog.Calls.DURATION
};
ContentResolver resolver = context.getContentResolver();
Cursor cur = resolver.query(
CallLog.Calls.CONTENT_URI,
projection,
null,
null,
CallLog.Calls.DEFAULT_SORT_ORDER );
if( !cur.isAfterLast()) {
int numberColumn = cur.getColumnIndex( CallLog.Calls.NUMBER );
int typeColumn = cur.getColumnIndex( CallLog.Calls.TYPE );
int durationcolumn = cur.getColumnIndex(CallLog.Calls.DURATION);
String number = cur.getString( numberColumn );
String type = cur.getString( typeColumn );
String duration = cur.getString(durationcolumn);
cur.moveToNext();
}
}