1. Are you ready for the Galaxy S20? Here is everything we know so far!

WiFi Distance Application

Discussion in 'Android Development' started by tsutttra12, Oct 6, 2014.

  1. tsutttra12

    tsutttra12 Lurker
    Thread Starter

    Hello All,
    I have a project I'm working on and I'm trying to validate the technology using an android application. Getting Straight to the point here's what I want to do.

    End Goal: I want to triangulate a position with three 802.11 WiFi signals

    Currently: I'm trying to find a distance from a transmitter to a receiver

    Transmitter: 802.11N router(It will be one specific domain so I will know the transmission strength)

    Receiver: Samsung Note 3 802.11AC wifi chip

    Process:

    First Thing I wanted to do was write an app that scanned available routers and put them in a list with their respective signal strengths.

    While doing this I ran into errors with the list view. I used some example code from Stack Overflow and the error is in the following Line.
    [HIGH]this.adapter = new SimpleAdapter(WiFiDemo.this, arraylist, R.layout.row, new String[] { ITEM_KEY }, new int[] { R.id.list_value });[/HIGH]
    the specific problems are that I can't find where to set two Id's
    [HIGH]R.layout.row[/HIGH]
    [HIGH]R.id.list_value[/HIGH]

    my direct assumption was that it was a property of the listview but i was unable to find it.

    Moving on from that I'm curious if anyone knows:
    1: Is there a way to remotely pull a meta-like transmission strength from WiFi Router

    2: (Pure curiosity)Is there a way to programatically access the hotspot feature?

    I've read in a lot of places that pulling distance like this is not do-able. WiFi is a radio signal and people have done this with Time of Flight And signal strength with radio signals before I know it's possible.


    Thanks to anyone who can help
     



    1. Download the Forums for Android™ app!


      Download

       
  2. IrvineCAGuy

    IrvineCAGuy Lurker

    There are some example wifi programs that returns a list of wifi spots found. In the data is the signal strength. You will need to get at that value(s) and do you own calculations as to distance....which is not always accurate. At best you CAN get signal strengths. Try this code:

    TextView mainText;
    WifiManager mainWifi;
    WifiReceiver receiverWifi;
    List<ScanResult> wifiList;
    StringBuilder sb = new StringBuilder();

    public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, 0, 0, "Refresh");
    return super.onCreateOptionsMenu(menu);
    }

    public boolean onMenuItemSelected(int featureId, MenuItem item) {
    mainWifi.startScan();
    mainText.setText("Starting Scan");
    return super.onMenuItemSelected(featureId, item);
    }

    protected void onPause() {
    unregisterReceiver(receiverWifi);
    super.onPause();
    }

    protected void onResume() {
    registerReceiver(receiverWifi, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
    super.onResume();
    }

    class WifiReceiver extends BroadcastReceiver {
    public void onReceive(Context c, Intent intent) {
    sb = new StringBuilder();
    wifiList = mainWifi.getScanResults();
    for(int i = 0; i < wifiList.size(); i++){
    sb.append(new Integer(i+1).toString() + ".");
    sb.append((wifiList.get(i)).toString());
    sb.append("\\n");
    }
    mainText.setText(sb);
    }
    }
     
Loading...

Share This Page

Loading...