70 likes | 292 Views
skyhook. Get skyhook SDK from skyhookwireless.com and decompress Start a new project with a button and onClickListener Import SkyHookWireless.jar In eclipse, right click on src folder Select build path Select configure Select Libraries tab click “add external jar” button
E N D
Get skyhook SDK from skyhookwireless.com and decompress • Start a new project with a button and onClickListener • Import SkyHookWireless.jar • In eclipse, right click on src folder • Select build path • Select configure • Select Libraries tab • click “add external jar” button • Navigate and select the SkyHookWireless.jar file, which is in the SkyHookWireless/lib folder where the SkyHook SDK was decompressed • THEN, select Order and Export tab, and select wpsapi.jar • Go to your java source, at the top type import com.skyhookwireless.*;
(see skyhookwireless quick start information for up to date information) • Set permissions • Internet • CHANGE_WIFI_STATE • ACCESS_WIFI_STATE • ACCEESS_CORSE_LOCATION • ACCESS_FINE_LOCATION • ACCESS_WAKE_LOCK
In main activity, in this case SkyHookTest • Add variables • WPS wps = null; • WPSAuthentication auth = null; • In onClickListener (for the button you made), add • wps = new WPS(SkyHookTest.this); • auth = new WPSAuthentication("bohacek", "udel"); • wps.getLocation(auth, WPSStreetAddressLookup.WPS_NO_STREET_ADDRESS_LOOKUP, callback);
WPSLocationCallback callback = new WPSLocationCallback() { intcnt = 0; public void done() { cnt = 0; Log.d("skyhooktest","done"); // after done() returns, you can make more WPS calls. } public WPSContinuationhandleError(WPSReturnCode error) { Log.d("skyhooktest","error code="+error); if (cnt++<10) return WPSContinuation.WPS_CONTINUE; //try again else return WPSContinuation.WPS_STOP; } public void handleWPSLocation(WPSLocation location) { Log.d("skykooktest","lat="+location.getLatitude()+" long="+location.getLongitude()); } }; run
Instead of wps, use xps to include gps, i.e., • Instead of • WPS wps = null; • Use • XPS xps= null; • Instead of • wps = new WPS(SkyHook2.this); • Use • xps = new XPS(SkyHook2.this); • Instead of • wps.getLocation(auth, WPSStreetAddressLookup.WPS_NO_STREET_ADDRESS_LOOKUP, callback); • Use • xps.getLocation(auth, WPSStreetAddressLookup.WPS_NO_STREET_ADDRESS_LOOKUP, callback);