问题
Ok, guys, here's my code for getting SMS:
Cursor cursor = getContentResolver().query(Uri.parse(uri),
null, CallLog.Calls.DATE + " > " + lastSmsTime, null,
CallLog.Calls.DATE + " ASC");
Where type is:
"content://sms/inbox"
"content://sms/sent"
And for calls:
String[] projection = new String[] { CallLog.Calls.NUMBER,
CallLog.Calls.TYPE, CallLog.Calls.DURATION, CallLog.Calls.DATE };
Cursor managedCursor = getContentResolver().query(
CallLog.Calls.CONTENT_URI, projection,
CallLog.Calls.DATE + " > " + lastCallTime, null,
CallLog.Calls.DATE + " ASC");
First of all, I know that this is undocumented provider(as you see, I use column constants from different one).
Funny thing is that this is working ok on several 2.3.x devices. But now I tried this on Galaxy S II(ICS 4.0.3). Now all SMS are duplicated in calls provider.
Has anyone come across this issue?
UPD I found the same question here, keep looking for the solution.
UDD 2 from what I know now, Samsung now stores everything in one log, so I'll try to find a way to reverse-engineer log application.
Anyway, still looking for solution to separate sms and calls.
回答1:
Ok, that's might be the solution, so I'm posting it: Samsung logs provider has lot's of columns, among them is
logtype
which, as far as I see, for calls is 100, for SMS is 300 and for MMS is 200.
It's also possible to detect manufacturer:
String man = android.os.Build.MANUFACTURER;
So, for samsung devices there should be separate code which will check the logtype.
回答2:
Just been looking at this myself. A more generic solution is to eliminate all incoming call entries with a duration of 0.
回答3:
Cursor query = this.managedQuery(
CallLog.Calls.CONTENT_URI, null, CallLog.Calls.TYPE + " in ('3','5') OR " + CallLog.Calls.DURATION + ">0 ", null, null);
//Calls.Type is 3 for Missed Calls and 5 for Cancelled Calls and **Calls.Duration** is 0 for Message, Missed Calls and Cancelled Calls
This code worked fine for me. I had went to 3-4 other links but all of them suggested to delete the Log of Message from CallLog. This is probably the only way to get only Voice Call Logs by not writing/deleting from any log
来源:https://stackoverflow.com/questions/11294563/sms-are-duplicated-as-callssamsung-galaxy-s-ii