I am trying to compare the type of calls with 'missed' calls.
I am using CallLog.Calls.TYPE to do this, but the I don't get desired output inside the app.
Below is the code.
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);
}
Rohit5k2
18.1k8 gold badges48 silver badges58 bronze badges
asked Feb 11, 2016 at 20:52
asad_hussain
2,0611 gold badge20 silver badges28 bronze badges
-
I want to know that am i doing the comparison in the right way ??asad_hussain– asad_hussain2016年02月11日 20:53:27 +00:00Commented Feb 11, 2016 at 20:53
-
What is your desired output?Rohit5k2– Rohit5k22016年02月11日 20:55:05 +00:00Commented Feb 11, 2016 at 20:55
-
I want to list all missed calls.asad_hussain– asad_hussain2016年02月11日 20:56:03 +00:00Commented Feb 11, 2016 at 20:56
1 Answer 1
You are not comparing correctly. You are comparing the constants. You need to compare with the values inside the Cursor you fetched using ContentResolver like this
If cursor is the result of your query then do this
String callType = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.TYPE));
and then
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);
}
answered Feb 11, 2016 at 21:04
Rohit5k2
18.1k8 gold badges48 silver badges58 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Rohit5k2
Perfect. Please don't forget to accept the answer if it helped you.
default