我正在尝试将通话类型与“错过”#39;调用
我正在使用CallLog.Calls.TYPE
来执行此操作,但我在应用内部无法获得所需的输出。
以下是代码。
if (Integer.parseInt(CallLog.Calls.TYPE)==CallLog.Calls.MISSED_TYPE) {
dir = "MISSED";
sb.append("\nName: " + namee + "\nPhone Number: " + phNumber + " \nCall Type: " + dir + " \nCall Date: " + callDayTime
+ " \nCall duration in sec : " + callDuration);
}
答案 0 :(得分:3)
您没有正确比较。你正在比较常数。您需要与使用Cursor
提取的ContentResolver
内的值进行比较
如果您的查询结果为cursor
,请执行此操作
String callType = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.TYPE));
然后
if(Integer.parseInt(callType) == CallLog.Calls.MISSED_TYPE ){
dir = "MISSED";
sb.append("\nName: " + namee + "\nPhone Number: " + phNumber + " \nCall Type: " + dir + " \nCall Date: " + callDayTime
+ " \nCall duration in sec : " + callDuration);
}