当前位置: 首页>>代码示例>>Java>>正文


Java LocationManager.NETWORK_PROVIDER属性代码示例

本文整理汇总了Java中android.location.LocationManager.NETWORK_PROVIDER属性的典型用法代码示例。如果您正苦于以下问题:Java LocationManager.NETWORK_PROVIDER属性的具体用法?Java LocationManager.NETWORK_PROVIDER怎么用?Java LocationManager.NETWORK_PROVIDER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.location.LocationManager的用法示例。


在下文中一共展示了LocationManager.NETWORK_PROVIDER属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: provide

@Override
protected void provide() {
    Looper.prepare();
    locationManager = (LocationManager) this.getContext().getSystemService(Context.LOCATION_SERVICE);
    locationListener = new MyLocationListener();

    long minTime = 0;
    float minDistance = 0;
    String provider;
    if (Geolocation.LEVEL_EXACT.equals(level)) {
        provider = LocationManager.GPS_PROVIDER;
    }
    else {
        provider = LocationManager.NETWORK_PROVIDER;
    }
    locationManager.requestLocationUpdates(provider, minTime, minDistance, locationListener);
    Looper.loop();
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:18,代码来源:CurrentLocationProvider.java

示例2: refreshLastKnownLocation

/**
 * Requests an updated location if the last known location is older than maxAge milliseconds.
 *
 * Note: this must be called only on the UI thread.
 */
@SuppressFBWarnings("LI_LAZY_INIT_UPDATE_STATIC")
static void refreshLastKnownLocation(Context context, long maxAge) {
    ThreadUtils.assertOnUiThread();

    // We're still waiting for a location update.
    if (sListener != null) return;

    LocationManager locationManager =
            (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    if (location == null || getLocationAge(location) > maxAge) {
        String provider = LocationManager.NETWORK_PROVIDER;
        if (locationManager.isProviderEnabled(provider)) {
            sListener = new SelfCancelingListener(locationManager);
            locationManager.requestSingleUpdate(provider, sListener, null);
        }
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:23,代码来源:GeolocationTracker.java

示例3: provide

@Override
protected void provide() {
    Looper.prepare();
    locationManager = (LocationManager) this.getContext().getSystemService(Context.LOCATION_SERVICE);
    locationListener = new MyLocationListener();

    long minTime = this.interval;
    float minDistance = 0;
    String provider;
    if (Geolocation.LEVEL_EXACT.equals(level)) {
        provider = LocationManager.GPS_PROVIDER;
    }
    else {
        provider = LocationManager.NETWORK_PROVIDER;
    }
    locationManager.requestLocationUpdates(provider, minTime, minDistance, locationListener);
    Looper.loop();
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:18,代码来源:LocationUpdatesProvider.java

示例4: onCreate

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LogHelper.verboseLog(TAG,
            "File name: \"" +
                    Thread.currentThread().getStackTrace()[2].getFileName() +
                    "\", Line number: " +
                    Thread.currentThread().getStackTrace()[2].getLineNumber() +
                    ", Class name: \"" +
                    Thread.currentThread().getStackTrace()[2].getClassName() +
                    "\", Method name: \"" +
                    Thread.currentThread().getStackTrace()[2].getMethodName() +
                    "\"");

    if (Configuration.sIsFeatureLocationAvailable) {
        if (Configuration.sIsFeatureLocationNetworkAvailable) {
            mNetworkProvider = LocationManager.NETWORK_PROVIDER;
        }

        if (Configuration.sIsFeatureLocationGpsAvailable) {
            mGpsProvider = LocationManager.GPS_PROVIDER;
        }

        mPassiveProvider = LocationManager.PASSIVE_PROVIDER;
    }
}
 
开发者ID:n37bl4d3,项目名称:Android-Location-Tracker,代码行数:26,代码来源:OptionsTabFragment.java

示例5: onConnected

@Override
public void onConnected(@Nullable Bundle bundle) {
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
            != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.ACCESS_FINE_LOCATION},1);

    }
    else {
        locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
        String locationProvider = LocationManager.NETWORK_PROVIDER;

       // mLastLocation = locationManager.getLastKnownLocation(locationProvider);

        mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
                mGoogleApiClient);

        if (mLastLocation != null) {
            try {
                Get_intent(); //Fetch Intent Values
            }catch (Exception e){
                Log.d(TAG, "onCreate: Intent Error");
            }
        }
    }

    startLocationUpdates();
}
 
开发者ID:KrishAmal,项目名称:NavAR,代码行数:28,代码来源:ArCamActivity.java

示例6: getLocation

public void getLocation(Fragment fragment) {
    this.fragment = fragment;
    boolean locationPermissionFlag = util.checkPermission(locationPermissions,
            activity);
    if (locationPermissionFlag) {
        fragment.requestPermissions(locationPermissions, Configure.LOCATION_PERMISSION_CODE);
    }else{
        locationManager = (LocationManager) activity.getSystemService(Context.
                LOCATION_SERVICE);
        String provider;
        List<String> providerList = locationManager.getProviders(true);
        if (providerList.contains(LocationManager.GPS_PROVIDER)) {
            provider = LocationManager.GPS_PROVIDER;
        } else if (providerList.contains(LocationManager.NETWORK_PROVIDER)) {
            provider = LocationManager.NETWORK_PROVIDER;
        } else {
            Toast.makeText(activity, "请连接网络或打开GPS",
                    Toast.LENGTH_LONG).show();
            return;
        }
        Location location = locationManager.getLastKnownLocation(provider);
        locationManager.requestLocationUpdates(provider, 2000, 10, this);
        if (location != null) {
            getLocation(location);
        }
    }
}
 
开发者ID:victorySSS,项目名称:readingNotes,代码行数:27,代码来源:LocationUtil.java

示例7: initLocation

private void initLocation() {
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=
            PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        return;
    }

    mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    List<String> providers = mLocationManager.getProviders(true);

    String locationProvider;
    /**
     * 如果首选GPS定位,会存在这种情况,上次GPS启动采集数据在A地,本次在B地需要定位,但用户恰好在室内无
     * GPS信号,只好使用上次定位数据,就出现了地区级偏差。而网络定位则更具有实时性,在精度要求不高以及室内
     * 使用场景更多的前提下,首选网络定位
     */
    if (providers.contains(LocationManager.NETWORK_PROVIDER)) {
        locationProvider = LocationManager.NETWORK_PROVIDER; // 首选网络定位
    } else if (providers.contains(LocationManager.GPS_PROVIDER)) {
        locationProvider = LocationManager.GPS_PROVIDER;
    } else {
        locationProvider = LocationManager.PASSIVE_PROVIDER;
    }

    if (mLocationListener != null)
        mLocationManager.requestLocationUpdates(locationProvider, 2000, 10, mLocationListener);
}
 
开发者ID:woxingxiao,项目名称:GracefulMovies,代码行数:27,代码来源:LocationService.java

示例8: getLocation

public Location getLocation() {

        Location location = new Location(LocationManager.NETWORK_PROVIDER);
        location.setLatitude(getLatitude());
        location.setLongitude(getLongitude());
        return location;
    }
 
开发者ID:tjjh89017,项目名称:DoorAccess,代码行数:7,代码来源:ReaderLocation.java

示例9: getValidProvider

@Nullable
private static String getValidProvider(LocationManager locationManager, boolean highAccuracy) {
  String provider =
      highAccuracy ? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER;
  if (!locationManager.isProviderEnabled(provider)) {
    provider = provider.equals(LocationManager.GPS_PROVIDER)
        ? LocationManager.NETWORK_PROVIDER
        : LocationManager.GPS_PROVIDER;
    if (!locationManager.isProviderEnabled(provider)) {
      return null;
    }
  }
  return provider;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:14,代码来源:LocationModule.java

示例10: update

@Override
public void update() {
  currentProvider = LocationManager.NETWORK_PROVIDER;
}
 
开发者ID:mapbox,项目名称:mapbox-events-android,代码行数:4,代码来源:AndroidLocationEngine.java


注:本文中的android.location.LocationManager.NETWORK_PROVIDER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。