android.location.LocationManager.addTestProvider()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(448)

本文整理了Java中android.location.LocationManager.addTestProvider()方法的一些代码示例,展示了LocationManager.addTestProvider()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocationManager.addTestProvider()方法的具体详情如下:
包路径:android.location.LocationManager
类名称:LocationManager
方法名:addTestProvider

LocationManager.addTestProvider介绍

暂无

代码示例

代码示例来源:origin: Phantast/smartnavi

public static void reactivateFakeProvider() {
  if (BuildConfig.debug)
    Log.i("Location-Status", "reactivate Fake Provider");
  try {
    mocLocationProvider = LocationManager.GPS_PROVIDER;
    geoLocationManager.addTestProvider(mocLocationProvider, false, false, false, false, true, true, true, 0, 5);
    geoLocationManager.setTestProviderEnabled(mocLocationProvider, true);
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: johncarpenter/Android-GPX-Mock-Location-Provider

private void setupTestProvider() {
  mLocationManager.addTestProvider(PROVIDER_NAME, false, //requiresNetwork,
      false, // requiresSatellite,
      false, // requiresCell,
      false, // hasMonetaryCost,
      false, // supportsAltitude,
      false, // supportsSpeed, s
      false, // upportsBearing,
      Criteria.POWER_LOW, // powerRequirement
      Criteria.ACCURACY_FINE); // accuracy
  mLocationManager.setTestProviderEnabled("gps", true);
}

代码示例来源:origin: luv/mockgeofix

protected void _register() {
  // if the test provider already exists, android handles this fine
  try {
    mLocationManager.addTestProvider(locationProviderName, false, false, false,
        false, true, true, true, 0, accuracy);
    mLocationManager.setTestProviderEnabled(locationProviderName, true);
  } catch (IllegalArgumentException ex) {
    Log.e(TAG, "IllegalArgumentException thrown in _register");
  }
}

代码示例来源:origin: amotzte/android-mock-location-for-development

MockLocationProvider(String name, Context ctx) {
  this.providerName = name;
  this.ctx = ctx;
  LocationManager lm = (LocationManager) ctx.getSystemService(
      Context.LOCATION_SERVICE);
  lm.addTestProvider(providerName, false, false, false, false, false,
      true, true, 0, 5);
  lm.setTestProviderEnabled(providerName, true);
}

代码示例来源:origin: openxc/openxc-android

private void overwriteNativeProvider() {
  if(mOverwriteNativeStatus && !mNativeGpsOverridden && mLocationManager != null) {
    try {
      mLocationManager.addTestProvider(LocationManager.GPS_PROVIDER,
          false, false, false, false, false, true, false, 0, 5);
      mLocationManager.setTestProviderEnabled(
          LocationManager.GPS_PROVIDER, true);
    } catch(SecurityException e) {
      Log.w(TAG, "Unable to use mocked locations, " +
          "insufficient privileges - make sure mock locations " +
          "are allowed in device settings", e);
    }
  }
}

代码示例来源:origin: openxc/openxc-android

private void setupMockLocations() {
    try {
      if(mLocationManager.getProvider(
            VEHICLE_LOCATION_PROVIDER) == null) {
        mLocationManager.addTestProvider(VEHICLE_LOCATION_PROVIDER,
            false, false, false, false, false, true, false, 0, 5);
      }
      mLocationManager.setTestProviderEnabled(
          VEHICLE_LOCATION_PROVIDER, true);
    } catch(SecurityException e) {
        Log.w(TAG, "Unable to use mocked locations, " +
            "insufficient privileges - make sure mock locations " +
            "are allowed in device settings", e);
      mLocationManager = null;
    }
  }
}

代码示例来源:origin: stackoverflow.com

//Instantiate in your activity
 LocationManager lm = getSystemService(LOCATION_SERVICE);
 //Add a test provider
 lm.addTestProvider("myprovider", false, false, false, false, true, true, true, Criteria.POWER_HIGH, Criteria.ACCURACY_FINE);
 //Update the last location your provider will serve
 Location fakeLoc = ...;
 lm.setTestProviderLocation("myprovider", fakeLoc);
 //Using your custom location provider
 LocationProvider customProvider = lm.getProvider("myprovider");

代码示例来源:origin: stackoverflow.com

mLocationManager.addTestProvider(GPS_PROVIDER, false, false, false, 
false, false, true, true, 0, 5);
mLocationManager.setTestProviderEnabled(GPS_PROVIDER, true);

代码示例来源:origin: stackoverflow.com

public void test1_TestCaseFoo()
 {
   Location location = new Location("network");
   location.setLatitude(-15.83554363);
   location.setLongitude(-48.01770782);
   location.setTime(new Date().getTime());
   location.setAccuracy(100.0f);
   location.setElapsedRealtimeNanos(System.nanoTime());
   LocationManager locationManager = (LocationManager) getInstrumentation().getTargetContext().getSystemService(Context.LOCATION_SERVICE);
   locationManager.addTestProvider(LocationManager.GPS_PROVIDER, false, false, false, false, true, true, true, Criteria.POWER_LOW, Criteria.ACCURACY_FINE);
   locationManager.setTestProviderStatus(LocationManager.GPS_PROVIDER, LocationProvider.AVAILABLE, null, System.currentTimeMillis());
   locationManager.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true);
   locationManager.setTestProviderLocation(LocationManager.GPS_PROVIDER, location);
   locationManager.addTestProvider(LocationManager.NETWORK_PROVIDER, false, false, false, false, true, true, true, Criteria.POWER_LOW, Criteria.ACCURACY_FINE);
   locationManager.setTestProviderStatus(LocationManager.NETWORK_PROVIDER, LocationProvider.AVAILABLE, null, System.currentTimeMillis());
   locationManager.setTestProviderEnabled(LocationManager.NETWORK_PROVIDER, true);
   locationManager.setTestProviderLocation(LocationManager.NETWORK_PROVIDER, location);
   mActivity = getActivity();
   ....

代码示例来源:origin: Phantast/smartnavi

geoLocationManager.addTestProvider(mocLocationProvider, false, false, false, false, true, true, true, 1, 5);
geoLocationManager.setTestProviderEnabled(mocLocationProvider, true);
geoLocationManager.setTestProviderStatus(mocLocationProvider, 2, null, System.currentTimeMillis());

代码示例来源:origin: stackoverflow.com

locationManager.addTestProvider(GPS_MOCK_PROVIDER, false, false,
    false, false, true, false, false, 0, 5);
locationManager.setTestProviderEnabled(GPS_MOCK_PROVIDER, true);

代码示例来源:origin: xbenjii/PokeMock

mLocationManager.addTestProvider(mockLocationProvider, true, true, true, false, true,
    true, true, 0, 5);
mLocationManager.setTestProviderEnabled(mockLocationProvider, true);

代码示例来源:origin: org.seleniumhq.selenium/selenium-android-driver

locManager.addTestProvider(locationProvider,
  true, true, true, true, true, true, true, 0, 5);
locManager.setTestProviderEnabled(locationProvider, true);

代码示例来源:origin: stackoverflow.com

LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 Criteria criteria = new Criteria();
 criteria.setAccuracy( Criteria.ACCURACY_FINE );
 String mocLocationProvider = LocationManager.GPS_PROVIDER;//lm.getBestProvider( criteria, true );
 if ( mocLocationProvider == null ) {
   Toast.makeText(getApplicationContext(), "No location provider found!", Toast.LENGTH_SHORT).show();
   return;
 }
 lm.addTestProvider(mocLocationProvider, false, false,
     false, false, true, true, true, 0, 5);
 lm.setTestProviderEnabled(mocLocationProvider, true);
 Location loc = new Location(mocLocationProvider);
 Location mockLocation = new Location(mocLocationProvider); // a string
 mockLocation.setLatitude(-26.902038);  // double
 mockLocation.setLongitude(-48.671337);
 mockLocation.setAltitude(loc.getAltitude());
 mockLocation.setTime(System.currentTimeMillis());
 mockLocation.setAccuracy(1);
 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
   mockLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
 }
 lm.setTestProviderLocation( mocLocationProvider, mockLocation);
 Toast.makeText(getApplicationContext(), "Working", Toast.LENGTH_SHORT).show();

代码示例来源:origin: Shimingli/PerformanceOptimizationForAndroid

mLocationManager.addTestProvider(LocationManager.GPS_PROVIDER,
    "requiresNetwork" == "", "requiresSatellite" == "", "requiresCell" == "", "hasMonetaryCost" == "",
    "supportsAltitude" == "", "supportsSpeed" == "",

相关文章