本文整理汇总了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());
}
}
示例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;
}
}
示例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());
}
}
}
示例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
}
}
示例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
}
}
示例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();
}
示例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();
}