0

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
3
  • I want to know that am i doing the comparison in the right way ?? Commented Feb 11, 2016 at 20:53
  • What is your desired output? Commented Feb 11, 2016 at 20:55
  • I want to list all missed calls. Commented Feb 11, 2016 at 20:56

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect. Please don't forget to accept the answer if it helped you.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.