简体   繁体   中英

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. Here is the example for hashSet.

Does adding a duplicate value to a HashSet/HashMap replace the previous value

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.

That's it...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM