當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。