2

I need to get the gps position of a person when it is staying inside a house.

GPS does not work inside the house, but I heared somebody explaining that in Android you should first check if GPS is available. If not the next step would be to localize the person based on the nearby wireless networks.

I am quite new to this, and I plan on developing a simple app in titanium. My question is: Can you localize somebody based on the wireless network when gps is not available? Can I get the location of people inside buildings?

Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
Ryan
  • 5,456
  • 25
  • 71
  • 129
  • How accurate does this need to be? Do you just need to figure out what neighborhood someone is in, or do you need to know within a foot or so of where someone is? – Brad Mar 29 '12 at 19:38

4 Answers4

0

you can call below cellID function where ever you want to get cellID location. It will not be as accurate as GPS

 public void cellID()
{
    TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);


    GsmCellLocation cellLocation = (GsmCellLocation)    telephonyManager.getCellLocation();     
      int cid = cellLocation.getCid();
      int lac = cellLocation.getLac();
      SimpleDateFormat sdfDateTime = new SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss");
        datetimeCellID = sdfDateTime.format(new Date());
      String cell_Id=String.valueOf(cid);
      String gsm_Loc_Area_Code=String.valueOf(lac);
    //  Toast.makeText(getBaseContext(),"cellid="+cell_Id+"\nGsm Location Area Code:"+gsm_Loc_Area_Code,Toast.LENGTH_LONG ).show();

      if(RqsLocation(cid, lac))
      {
          TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
            imeiCellID = tm.getDeviceId();
          latitude_cellID=String.valueOf((float)myLatitude/1000000);
          longitude_cellID=String.valueOf((float)myLongitude/1000000);
        // Toast.makeText(getBaseContext(),"Lat:"+latitude_cellID+"Long:"+longitude_cellID,Toast.LENGTH_LONG ).show();


      }//if
      else
      {
          Toast.makeText(getBaseContext(),"CellID : Can't find Location",Toast.LENGTH_LONG ).show();
      }//else 
     }

}//cellID

  private Boolean RqsLocation(int cid, int lac)
  {
      //Toast.makeText(getBaseContext(),"inReqloc",Toast.LENGTH_LONG ).show();
   Boolean result = false; 
   String urlmmap = "http://www.google.com/glm/mmap";

      try {
           URL url = new URL(urlmmap);
          URLConnection conn = url.openConnection();
          HttpURLConnection httpConn = (HttpURLConnection) conn;      
          httpConn.setRequestMethod("POST");
          httpConn.setDoOutput(true);
          httpConn.setDoInput(true);
          httpConn.connect();  
          OutputStream outputStream = httpConn.getOutputStream();
          WriteData(outputStream, cid, lac);       
          InputStream inputStream = httpConn.getInputStream();
          DataInputStream dataInputStream = new DataInputStream(inputStream);
          dataInputStream.readShort();
          dataInputStream.readByte();
          int code = dataInputStream.readInt();
          if (code == 0)
          {
           myLatitude = dataInputStream.readInt();
           myLongitude = dataInputStream.readInt();
           result = true;

          }
        } catch (IOException e) 
          {
            // TODO Auto-generated catch block
           e.printStackTrace(); 
          }

    return result;

  }

  private void WriteData(OutputStream out, int cid, int lac)
  throws IOException
  {    
      DataOutputStream dataOutputStream = new DataOutputStream(out);
      dataOutputStream.writeShort(21);
      dataOutputStream.writeLong(0);
      dataOutputStream.writeUTF("en");
      dataOutputStream.writeUTF("Android");
      dataOutputStream.writeUTF("1.0");
      dataOutputStream.writeUTF("Web");
      dataOutputStream.writeByte(27);
      dataOutputStream.writeInt(0);
      dataOutputStream.writeInt(0);
      dataOutputStream.writeInt(3);
      dataOutputStream.writeUTF(""); 
      dataOutputStream.writeInt(cid);
      dataOutputStream.writeInt(lac);    
      dataOutputStream.writeInt(0);
      dataOutputStream.writeInt(0);
      dataOutputStream.writeInt(0);
      dataOutputStream.writeInt(0);
      dataOutputStream.flush();    
  }  
user2686960
  • 25
  • 10
0

You ask the location provider for the best provider, if GPS is unavailable you will get location from cellID (mobile mast) or wireless network, see this and related stackoverflow question

Community
  • 1
  • 1
EdChum
  • 376,765
  • 198
  • 813
  • 562
0

Seems to be a good start, I hope this code may help:

try {
            gps_enabled = locManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        } catch (Exception ex) {
        }
        try {
            network_enabled = locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        } catch (Exception ex) {
        }

        // don't start listeners if no provider is enabled
        if (!gps_enabled && !network_enabled) {
            AlertDialog.Builder builder = new Builder(this);
            builder.setTitle("Attention!");
            builder.setMessage("Sorry, location is not determined. Please enable location providers");
            builder.create().show();
        }

        if (gps_enabled) {
            locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);
        }
        if (network_enabled) {
            locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locListener);
        }

From here: http://www.hrupin.com/2011/04/android-gps-using-how-to-get-current-location-example

Waza_Be
  • 39,407
  • 49
  • 186
  • 260
0

One option is Skyhook. Here's a link to their SDK. It is android compatible. This won't be as accurate as GPS but it will get you at least inside the correct building most of the time.

http://www.skyhookwireless.com/location-technology/sdk.php

James McCracken
  • 15,488
  • 5
  • 54
  • 62