Mat*_*ieu 7 notifications android telephony
在我的应用程序中,当呼叫到来但用户没有回答时,我应该做一些动作.
我在android.telephony和NotificationManager中搜索过,但是我还没有找到解决这个问题的方法.
有人知道如何知道手机上是否有未接来电?
Cam*_*gny 14
这是可以查询未接来电的通话记录的代码.基本上,你必须以某种方式触发这一点,并确保你给呼叫记录一些时间(几秒钟应该这样做)来写信息,否则如果你太快检查呼叫记录你将找不到最近的呼叫.
final String[] projection = null;
final String selection = null;
final String[] selectionArgs = null;
final String sortOrder = android.provider.CallLog.Calls.DATE + " DESC";
Cursor cursor = null;
try{
cursor = context.getContentResolver().query(
Uri.parse("content://call_log/calls"),
projection,
selection,
selectionArgs,
sortOrder);
while (cursor.moveToNext()) {
String callLogID = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls._ID));
String callNumber = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER));
String callDate = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.DATE));
String callType = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.TYPE));
String isCallNew = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NEW));
if(Integer.parseInt(callType) == MISSED_CALL_TYPE && Integer.parseInt(isCallNew) > 0){
if (_debug) Log.v("Missed Call Found: " + callNumber);
}
}
}catch(Exception ex){
if (_debug) Log.e("ERROR: " + ex.toString());
}finally{
cursor.close();
}
Run Code Online (Sandbox Code Playgroud)
希望这个对你有帮助.
| 归档时间: |
|
| 查看次数: |
15362 次 |
| 最近记录: |