SMS are duplicated as Calls(Samsung galaxy S II)

◇◆丶佛笑我妖孽 提交于 2019-12-10 11:49:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!