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;
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
add a comment |
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
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
add a comment |
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
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
java android
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Apr 19 at 18:17
Subir Kumar SaoSubir Kumar Sao
6,58111742
6,58111742
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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