Skip to content Skip to sidebar Skip to footer

Send Spoof Locations With Ddms Emulator Control To A Tablet Android Device

I want to test a GPS application I am developing in my android tablet, so I need to send to it spoof locations from a KML file loading it using DDMS. I want to use a physical devic

Solution 1:

I've pieced together a solution to this problem.

  • Go to Settings->Applications->Development and select "Allow mock locations".

  • Add ACCESS_MOCK_LOCATION permission to AndroidManifest.xml:

    <?xml version="1.0" encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android"><uses-permissionandroid:name="android.permission.ACCESS_MOCK_LOCATION">
  • Implement a class which uses the LocationManager.addTestProvider() function. This will indicate to the application that it should use data from a file to construct new Location objects.

  • New Locations can then be created using the LocationManager.setTestProviderLocation() function.

    // start using mock locationstry {
       mockLocationCreator = new MockLocationCreator(this.getApplicationContext());
       try {
           mockLocationCreator.openLocationList();
    
           mockLocationThread = new Thread(mockLocationCreator);
           mockLocationThread.start();
    
           Toast.makeText(this.getApplicationContext(), 
                          "Mock locations are in use", 
                          Toast.LENGTH_LONG)
                .show();
    
       } catch (IOException e) {
           Toast.makeText(this.getApplicationContext(), 
                          "Error: Unable to open / read data file", 
                          Toast.LENGTH_LONG)
                .show();
           mockLocationCreator = null;
       }
    } catch(SecurityException e) {
       Toast.makeText(this.getApplicationContext(), 
                      "Error: Insufficient Privileges", 
                       Toast.LENGTH_LONG)
            .show();
       Log.e(TAG, "unable to use mock locations, insufficient privileges", e);
    }
    

Note: It is not possible to send mock locations to a real device from DDMS->Emulator Control->Location Controls regardless of device or manifest permissions as is incorrectly suggested here.


Sources:

Android mock location on device? - information about manifest permissions and alternative solution using the telnet command line, links and code snippets.

Using Mock Locations in Android - more verbose, contains some dead links.

LocationManager Documentation - Official Android documentation

Solution 2:

For simple spoofing you can use this free version but as you said in your question you want spoof locations from a KML file for that you have to buy pro version

Post a Comment for "Send Spoof Locations With Ddms Emulator Control To A Tablet Android Device"