How to stop occurrence of same device again and againHow do I efficiently iterate over each entry in a Java Map?How do save an Android Activity state using save instance state?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How do I determine whether an array contains a particular value in Java?Why is the Android emulator so slow? How can we speed up the Android emulator?Stop EditText from gaining focus at Activity startupIs there a unique Android device ID?How do I convert a String to an int in Java?How do I fix android.os.NetworkOnMainThreadException?

Why did Nick Fury not hesitate in blowing up the plane he thought was carrying a nuke?

What to call a small, open stone or cement reservoir that supplies fresh water from a spring or other natural source?

Warped chessboard

Is it wise to pay off mortgage with 401k?

How to tease a romance without a cat and mouse chase?

Do seaplanes need to get clearance for takeoff?

Does a windmilling propeller create more drag than a stopped propeller in an engine out scenario?

Difference in 1 user doing 1000 iterations and 1000 users doing 1 iteration in Load testing

If the Charles SSL Proxy shows me sensitive data, is that data insecure/exposed?

400–430 degrees Celsius heated bath

Separate the element after every 2nd ',' and push into next row in bash

Why "strap-on" boosters, and how do other people say it?

Germany rejected my entry to Schengen countries

Filter a file list against an integer array?

Ribbon Cable Cross Talk - Is there a fix after the fact?

How to draw with Tikz a chord parallel to AC that passes through a point?

Statue Park: Five

Why are logically related bit fields in MCU registers often in separate locations

How to play vs. 1.e4 e5 2.Nf3 Nc6 3.Bc4 d6?

How could the B-29 bomber back up under its own power?

How can I use 400 ASA film in a Leica IIIf, which does not have options higher than 100?

Is there a way to generate a mapping graph like this?

Which one of these Isp's for the Dawn spacecraft is wrong?

How to prove the emptiness of intersection of two context free languages is undecidable?



How to stop occurrence of same device again and again


How do I efficiently iterate over each entry in a Java Map?How do save an Android Activity state using save instance state?How do I read / convert an InputStream into a String in Java?How do I generate random integers within a specific range in Java?How do I determine whether an array contains a particular value in Java?Why is the Android emulator so slow? How can we speed up the Android emulator?Stop EditText from gaining focus at Activity startupIs there a unique Android device ID?How do I convert a String to an int in Java?How do I fix android.os.NetworkOnMainThreadException?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm working on an android app that scans and listable device in a TextView . I'm not getting how to remove occurrence of same device again and again.



Below is the code i'm scanning devices. What amendments to make here?



private ScanCallback leScanCallback = new ScanCallback() 
@Override
public void onScanResult(int callbackType, ScanResult result)
t_c.append("Device Name: " + result.getDevice().getName()
+ " rssi: " + result.getRssi() + "n");


;









share|improve this question
























  • Maintain a Set<> probably.

    – Subir Kumar Sao
    Mar 24 at 5:15











  • @SubirKumarSao tried to maintain a list but that didn't work either. I'm an absolute noob to android.

    – Tara Singh
    Mar 24 at 8:33











  • List allows duplicate, Set does not. Before you append just check if data already in Set. if(devicSet.contains(device)).

    – Subir Kumar Sao
    Mar 25 at 17:49












  • @SubirKumarSao Thank you so much my problem is resolved :)

    – Tara Singh
    Mar 29 at 8:48

















0















I'm working on an android app that scans and listable device in a TextView . I'm not getting how to remove occurrence of same device again and again.



Below is the code i'm scanning devices. What amendments to make here?



private ScanCallback leScanCallback = new ScanCallback() 
@Override
public void onScanResult(int callbackType, ScanResult result)
t_c.append("Device Name: " + result.getDevice().getName()
+ " rssi: " + result.getRssi() + "n");


;









share|improve this question
























  • Maintain a Set<> probably.

    – Subir Kumar Sao
    Mar 24 at 5:15











  • @SubirKumarSao tried to maintain a list but that didn't work either. I'm an absolute noob to android.

    – Tara Singh
    Mar 24 at 8:33











  • List allows duplicate, Set does not. Before you append just check if data already in Set. if(devicSet.contains(device)).

    – Subir Kumar Sao
    Mar 25 at 17:49












  • @SubirKumarSao Thank you so much my problem is resolved :)

    – Tara Singh
    Mar 29 at 8:48













0












0








0


1






I'm working on an android app that scans and listable device in a TextView . I'm not getting how to remove occurrence of same device again and again.



Below is the code i'm scanning devices. What amendments to make here?



private ScanCallback leScanCallback = new ScanCallback() 
@Override
public void onScanResult(int callbackType, ScanResult result)
t_c.append("Device Name: " + result.getDevice().getName()
+ " rssi: " + result.getRssi() + "n");


;









share|improve this question
















I'm working on an android app that scans and listable device in a TextView . I'm not getting how to remove occurrence of same device again and again.



Below is the code i'm scanning devices. What amendments to make here?



private ScanCallback leScanCallback = new ScanCallback() 
@Override
public void onScanResult(int callbackType, ScanResult result)
t_c.append("Device Name: " + result.getDevice().getName()
+ " rssi: " + result.getRssi() + "n");


;






java android






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 5:13









Matt C

2,40541836




2,40541836










asked Mar 23 at 19:52









Tara SinghTara Singh

54




54












  • Maintain a Set<> probably.

    – Subir Kumar Sao
    Mar 24 at 5:15











  • @SubirKumarSao tried to maintain a list but that didn't work either. I'm an absolute noob to android.

    – Tara Singh
    Mar 24 at 8:33











  • List allows duplicate, Set does not. Before you append just check if data already in Set. if(devicSet.contains(device)).

    – Subir Kumar Sao
    Mar 25 at 17:49












  • @SubirKumarSao Thank you so much my problem is resolved :)

    – Tara Singh
    Mar 29 at 8:48

















  • Maintain a Set<> probably.

    – Subir Kumar Sao
    Mar 24 at 5:15











  • @SubirKumarSao tried to maintain a list but that didn't work either. I'm an absolute noob to android.

    – Tara Singh
    Mar 24 at 8:33











  • List allows duplicate, Set does not. Before you append just check if data already in Set. if(devicSet.contains(device)).

    – Subir Kumar Sao
    Mar 25 at 17:49












  • @SubirKumarSao Thank you so much my problem is resolved :)

    – Tara Singh
    Mar 29 at 8:48
















Maintain a Set<> probably.

– Subir Kumar Sao
Mar 24 at 5:15





Maintain a Set<> probably.

– Subir Kumar Sao
Mar 24 at 5:15













@SubirKumarSao tried to maintain a list but that didn't work either. I'm an absolute noob to android.

– Tara Singh
Mar 24 at 8:33





@SubirKumarSao tried to maintain a list but that didn't work either. I'm an absolute noob to android.

– Tara Singh
Mar 24 at 8:33













List allows duplicate, Set does not. Before you append just check if data already in Set. if(devicSet.contains(device)).

– Subir Kumar Sao
Mar 25 at 17:49






List allows duplicate, Set does not. Before you append just check if data already in Set. if(devicSet.contains(device)).

– Subir Kumar Sao
Mar 25 at 17:49














@SubirKumarSao Thank you so much my problem is resolved :)

– Tara Singh
Mar 29 at 8:48





@SubirKumarSao Thank you so much my problem is resolved :)

– Tara Singh
Mar 29 at 8:48












1 Answer
1






active

oldest

votes


















0














Answering for others.



The scan returning a device each time it finds one. There can be echo, same device found twice. OP wants to display only unique devices.



Solution:
Maintain a Set of Devices. Set data structure does not allow duplicate and solves the problem.



Once a new device is found add to deviceSet. Before adding check if device already exists. if(devicSet.contains(device)). If device already exists no-need to append to display.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55317747%2fhow-to-stop-occurrence-of-same-device-again-and-again%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Answering for others.



    The scan returning a device each time it finds one. There can be echo, same device found twice. OP wants to display only unique devices.



    Solution:
    Maintain a Set of Devices. Set data structure does not allow duplicate and solves the problem.



    Once a new device is found add to deviceSet. Before adding check if device already exists. if(devicSet.contains(device)). If device already exists no-need to append to display.






    share|improve this answer



























      0














      Answering for others.



      The scan returning a device each time it finds one. There can be echo, same device found twice. OP wants to display only unique devices.



      Solution:
      Maintain a Set of Devices. Set data structure does not allow duplicate and solves the problem.



      Once a new device is found add to deviceSet. Before adding check if device already exists. if(devicSet.contains(device)). If device already exists no-need to append to display.






      share|improve this answer

























        0












        0








        0







        Answering for others.



        The scan returning a device each time it finds one. There can be echo, same device found twice. OP wants to display only unique devices.



        Solution:
        Maintain a Set of Devices. Set data structure does not allow duplicate and solves the problem.



        Once a new device is found add to deviceSet. Before adding check if device already exists. if(devicSet.contains(device)). If device already exists no-need to append to display.






        share|improve this answer













        Answering for others.



        The scan returning a device each time it finds one. There can be echo, same device found twice. OP wants to display only unique devices.



        Solution:
        Maintain a Set of Devices. Set data structure does not allow duplicate and solves the problem.



        Once a new device is found add to deviceSet. Before adding check if device already exists. if(devicSet.contains(device)). If device already exists no-need to append to display.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 19 at 18:17









        Subir Kumar SaoSubir Kumar Sao

        6,58111742




        6,58111742





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55317747%2fhow-to-stop-occurrence-of-same-device-again-and-again%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript