简体   繁体   English

我想从通话记录中获取来电号码,但不重复该号码如果对相同号码重复该过程

[英]i Want to get incoming number from call log , but Without repeating the number If the process is repeated for the same number

this my code but it return repeating number 这是我的代码,但返回重复号

Cursor c = getApplicationContext().getContentResolver()
                .query(CallLog.Calls.CONTENT_URI, null, CallLog.Calls.TYPE+" = ? ",                        
                new String[]{String.valueOf(CallLog.Calls.INCOMING_TYPE)},
                CallLog.Calls.DATE + " DESC");

            ListView numListView = (ListView) findViewById(R.id.list);

            CallCursorAdapter adapter = new CallCursorAdapter(this, c);

            numListView.setAdapter(adapter);

You can use Hashset to remove duplicate value from your list. 您可以使用Hashset从列表中删除重复的值。 Here is the example for hashSet. 这是hashSet的示例。

Does adding a duplicate value to a HashSet/HashMap replace the previous value 是否将重复的值添加到HashSet / HashMap会替换先前的值

in the question you can see how they are adding value in the Hashset. 在问题中,您可以看到它们如何在哈希集中增加价值。 After adding value in the Hashset then pass this list your adapter. 在Hashset中添加值之后,然后将此列表传递给您的适配器。

That's it... 而已...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我不能编辑未保存来电号码的通话记录? - Why can't I edit the call log for an unsaved incoming number? 在 android 10 上以编程方式获取来电号码 - Get incoming call number programmatically on android 10 来自来电的电话号码无法正常工作 - phone number from incoming call not working android 获取来电号码? - Get the incoming phone number? 如何获取两个日期之间的呼叫日志数据以及两个日期之间的传入呼叫总数 - How to get the Call Log data between two dates and Total number of incoming an outgoing calls between the dates 如何从通话记录中获取号码并将其保存到对象-Android - How to get a number from the Call log and use it to save to an Object - Android Java中的随机,重复相同的数字 - Random in Java, repeating same number 对于 API &gt; 29 和 API &lt; 29 对于 Android 应用程序,我需要获取来电电话号码和该号码的通话记录的最低权限是多少? - What are the minimum permissions I need to get incoming phone number and call history for that number for API > 29 and API < 29 for Android app? 在PCI调制解调器上打入电话时如何获取电话号码 - How to get phone number when have an incoming call on PCI modem 如何在来电和去电过程中获取电话号码? - How to get the phone number during an incoming and outgoing call?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM