Skip to content Skip to sidebar Skip to footer

Deprecated Managedquery() Issue In Getting Call Logs

I have a method in which i am trying to get call logs of a phone. but because of deprecated ManagedQuery() i am not able to get that. Please help how can i modify that to meet my n

Solution 1:

You can replace your managedQuery with it :

CursormanagedCursor= getContentResolver().query(
                CallLog.Calls.CONTENT_URI, null, null, null, null);

Solution 2:

I found my answer here..

LoaderManager.LoaderCallbacks

Thanks everyone for the help!!!

Solution 3:

Do your UI update from the strings accordingly..

String[] details = newString[]{CallLog.Calls.NUMBER,
                    CallLog.Calls.TYPE,
                    CallLog.Calls.DURATION,
                    CallLog.Calls.CACHED_NAME,
                    CallLog.Calls._ID};

            Cursor cursor;

            cursor = context.getContentResolver().query(CallLog.Calls.CONTENT_URI, details, null, null, CallLog.Calls._ID + " DESC");
            if(cursor.getCount()!=0){
                cursor.moveToFirst();
                Stringnumber = cursor.getString(0);
                Stringtype=cursor.getString(1);
                String duration=cursor.getString(2);
                String name=cursor.getString(3);
                String id=cursor.getString(4);
                String dir = null;



                switch (Integer.parseInt(type)) {
                    caseCallLog.Calls.OUTGOING_TYPE:
                        dir = "OUTGOING";
                        break;

                    caseCallLog.Calls.INCOMING_TYPE:
                        dir = "INCOMING";
                        break;
                    caseCallLog.Calls.MISSED_TYPE:
                        dir = "MISSED";
                        break;
                }

            }
            cursor.close();

Post a Comment for "Deprecated Managedquery() Issue In Getting Call Logs"