Hello, I'm trying to create an app that scans for wifi. When the player does something in the game, it "consumes" the strongest wifi signal. That signal should no longer be detected on the next scan.
Anyone whos played Metal Gear Solid Portable ops would know what I mean.
I've spent a good 8 hours today trying to do this and now I'm lost.
The plan was to have the Briefing class load first. The Briefing Class looks for wireless signals after the player clicks the button "Search Town". It then returns the strongest wifi signal and it is ignored forever after scanning for Wifi again. The next the player clicks "Search Town", if the strongest signal happens to be the one scanned before, it is ignored and the second strongest signal is considered. Then that is ignored, and so on and so on. I tried to do this by creating a List of Wireless Signals that have already been scanned.
But its one problem after another. The Briefing class loads successfully, but when I click "Search Town", the app crashes.
Ulf Dittmer wrote:What does this code do now, what do you still want it to do, and where are you stuck implementing the missing parts?
Ok I've updated my opening post.
Joined: Mar 22, 2005
If an Android app crashes, then the first step is to examine the logcat output. It contains the full stack trace of the exception that caused the crash -including the line number of the of the piece of code where the crash happened- and generally points you in the direction of the problem.
Joined: Sep 28, 2011
Ok, it's working again. It's loading all the Wifi networks into a List, then it looks for the best Signal Strength. When the player presses "Search Town", it'll say in a Toast, "Found food and ammo at StarBucksWifi town". StarBucksWifi town is a wireless network with the best signal strength.
Now I want to make it so that when the player "gathers ammo and food" at Starbucks, the game will then ignore StarBucksWifi and find the strongest Signal Strength that isn't on an Ignore List. I've tried to figure this out myself, but I am at a lost.
Here's the code that worked.
Joined: Sep 28, 2011
This is what I want. Let's say there are three networks in range. Network A, B, and C. The app finds these networks and prints out only the strongest network...which is Network A. Once printed out, A is now ignored. The next time the app scans for networks, if it comes across network A again, it is ignored and declares Network B to be the strongest. My problem is that Network A continues to be printed out over and over and over again.
Every attempt to try and ignore previously used networks have failed. I tried using another list and adding used networks to it so that it won't be used again.
Either it crashes, or it continues to use the best network without the app ignoring it.
i think it's very easy. Here is the algorithm for you:
1) Make an object OOP like this:
2) Detect all networks
2) Put the strongest network inside the Object OOP above. Set the name,
set the foundstat to true. Put 'em into arraylist.
3) Detect all networks again.
4) Now let's check if the network found is similar to the network inside the arraylist?
5) If yes, dont print them out
6) If no, print them out and do the step 2 again repeatedly.
Hope you could figure out the code by yourself. I just simplify the
algorithm for you. CMIIW.
subject: Trying to collect wifi data like Metal Gear Solid Portable Ops