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


Java LocationAvailability.isLocationAvailable方法代码示例

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


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

示例1: SendLocation

import com.google.android.gms.location.LocationAvailability; //导入方法依赖的package包/类
public void SendLocation(){
    try {
        LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
        if (locationAvailability.isLocationAvailable()) {
            // Call Location Services
            LocationRequest locationRequest = new LocationRequest()
                    .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
                    .setInterval(10000)//10second
                    .setFastestInterval(5000);//5second
            LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
            Log.v("SendLocation",locationAvailability.toString());
        } else {
            // Do something when Location Provider not available
            Toast.makeText(getApplicationContext()
                    , "Please Open Location Provider"
                    , Toast.LENGTH_SHORT).show();
        }
    }
    catch (Exception e){
        Log.v("SendLocation exception",e.toString());
    }
}
 
开发者ID:Popati,项目名称:Android-BluetoothSPPLibrary-master,代码行数:23,代码来源:RSSPullService.java

示例2: checkLocationAvailability

import com.google.android.gms.location.LocationAvailability; //导入方法依赖的package包/类
private boolean checkLocationAvailability() {
    if (!googleApiClient.isConnected() || !permissionGranted) return false;
    try {
        LocationAvailability la = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
        return (la != null && la.isLocationAvailable());
    } catch (SecurityException e) {
        if (!quiet)
            Log.e(getClass().getSimpleName(), "Error while checking location availability:\n " + e.toString());
        if (listener != null)
            listener.onError(ErrorType.RETRIEVAL, "Could not check location availability:\n" +
                    e.getMessage());
        return false;
    }
}
 
开发者ID:klaasnotfound,项目名称:LocationAssistant,代码行数:15,代码来源:LocationAssistant.java

示例3: insertGyroTOserver

import com.google.android.gms.location.LocationAvailability; //导入方法依赖的package包/类
public void insertGyroTOserver(final String dt,final String x, final String y, final String z)
    {
        if(lat!=0 || lng!=0) {
            try {
                LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
                if (locationAvailability.isLocationAvailable()) {
                    // Call Location Services
                    LocationRequest locationRequest = new LocationRequest()
                            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
                    LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
                }
//                String queryString = createQueryString(params);
                final String SITE_URL = "http://168.63.175.28/addGyro.php";
                TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
                RequestBody formBody = new FormEncodingBuilder()
                        .add("isAdd", "true")
                        .add("imei", telephonyManager.getDeviceId())
                        .add("time",dt)
                        .add("x", x)
                        .add("y", y)
                        .add("z", z)
                        .add("lat",String.valueOf(lat))
                        .add("lng",String.valueOf(lng))
                        .build();
                PostForm p= new PostForm(formBody,SITE_URL);
                final Toast toast = Toast.makeText(getApplicationContext(), "มีการกระแทกเกิดขึ้น", Toast.LENGTH_SHORT);
//                toast.show();
            }
            catch (Exception ex) {
                Log.v("ex", ex.toString());
            }
        }
    }
 
开发者ID:Popati,项目名称:Android-BluetoothSPPLibrary-master,代码行数:34,代码来源:RSSPullService.java

示例4: Start

import com.google.android.gms.location.LocationAvailability; //导入方法依赖的package包/类
public void Start(View view){
    LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
    if (locationAvailability.isLocationAvailable()) {
        // Call Location Services
        LocationRequest locationRequest = new LocationRequest()
                .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
        LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    } else {
        // Do something when Location Provider not available
    }
}
 
开发者ID:Popati,项目名称:Android-BluetoothSPPLibrary-master,代码行数:12,代码来源:GoogleLocation.java

示例5: Stop

import com.google.android.gms.location.LocationAvailability; //导入方法依赖的package包/类
public void Stop(View view){
    LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient);
    if (locationAvailability.isLocationAvailable()) {
        // Call Location Services
        LocationRequest locationRequest = new LocationRequest()
                .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
        LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, this);
    } else {
        // Do something when Location Provider not available
    }
}
 
开发者ID:Popati,项目名称:Android-BluetoothSPPLibrary-master,代码行数:12,代码来源:GoogleLocation.java

示例6: onConnected

import com.google.android.gms.location.LocationAvailability; //导入方法依赖的package包/类
@Override
public void onConnected(Bundle connectionHint) {
    Log.i("CaptureActivity", "onConnected called");
    clientReady = true;

    //Use a new thread to request location updates for the worker thread.
    //This new thread waits until the result of the request for updates is complete.
    Runnable r = new Runnable(){
        @Override
        public void run() {
            LocationRequest request = new LocationRequest();
            request.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY).setInterval(5000);

            LocationCallback locationCallback = new LocationCallback() {
                @Override
                public void onLocationAvailability(LocationAvailability availability) {
                    if (!availability.isLocationAvailable()) {
                        locationReady = false;
                    }
                }

                public void onLocationResult(LocationResult result) {
                    newestLocation = result.getLastLocation();
                }
            };

            PendingResult<Status> requestResult = LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, request, locationCallback, handler.getLooper());
            Status requestStatus = requestResult.await();
            locationReady = true;
            if(requestStatus.isSuccess()) {
                locationReady = true;
                Log.i("CaptureActivity", "Location update request result success!");
            }else {
                Log.i("CaptureActivity", "Location update request result: failure!");
            }
        }
    };
    new Thread(r).start();
}
 
开发者ID:fultonms,项目名称:drivedata,代码行数:40,代码来源:CaptureActivity.java

示例7: onConnected

import com.google.android.gms.location.LocationAvailability; //导入方法依赖的package包/类
@Override
public void onConnected(Bundle bundle) {

    Log.d(TAG, "onConnected()..." ) ;
    locationLastKnown = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);

    if ( locationLastKnown == null ) {
        LocationAvailability locationAvailability = LocationServices.FusedLocationApi.getLocationAvailability(googleApiClient) ;
        if( locationLastKnown == null ){
            LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, createLocationRequest(), new LocationListener() {
                @Override
                public void onLocationChanged(Location location) {
                    locationLastKnown = location;

                    Log.d(TAG, "LocationServices.FusedLocationApi.requestLocationUpdate)/onLocationChanged()...locationLastKnown=" + locationLastKnown ) ;

                    refreshPositionOnMap();

                }
            });
        }


        boolean locationAvailabilityFlag= false ;

        if ( locationAvailability != null ) {
            locationAvailabilityFlag = locationAvailability.isLocationAvailable() ;
        }

        Log.d(TAG, "onConnected()...locationAvailability=" + locationAvailability  ) ;
    }

    Log.d(TAG, "onConnected()...locationLastKnown=" + locationLastKnown ) ;

    refreshPositionOnMap();

}
 
开发者ID:smitzey,项目名称:wearbooksource,代码行数:38,代码来源:WMapHandheldActivity.java


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