Silk Mobile

Table of Contents (Homepage)

SetLocation

setLocation(Latitude, Longitude)

images/images/os-icons/os_android_150x150.png

Description

The command gives the ability to test geolocation based applications by allowing the user to set the location of the device as necessary for testing. It is assumed that the user has pre-configured the device for location testing.

Note: To configure the device for location testing, the user should:

  1. Enter the “developer options” settings menu and check the “Allow mock locations” check box.

  2. Enter the "Location" settings menu and set the device location accuracy mode to "Device sensors only (GPS only)"

Parameters

  • Latitude: Latitude value in decimal degrees, ranging from -90 to 90.
    Positive values represent latitudes north of the equator while negative values represent latitudes south of the equator.

  • Longitude: Longitude value in decimal degrees, ranging from -180 to 180.
    Positive values represent longitudes east of the prime meridian while negative values represent longitudes west of the prime meridian.

Usage

client.setDevice("adb:GT-I9505");
client.setLocation("20.593684", "78.962880");  // India
client.setLocation("-32.269794", "26.191406"); // South Africa
client.setLocation("36.296238", "-91.933594"); // USA


images/download/attachments/3309768/5.jpg images/download/attachments/3309768/6.jpg images/download/attachments/3309768/7.jpg

Note: For the device to return to it’s normal location functioning, it is required to execute the command “clearLocation”.

Code Examples

Java Example
client.setLocation("20.593684", "78.962880");
C# Example
client.SetLocation("20.593684", "78.962880");
VBScript Example
client.SetLocation "20.593684", "78.962880"
Report
Python Example
self.client.setLocation("20.593684", "78.962880")
Perl Example
$client->setLocation("20.593684", "78.962880");