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


Java LocationResult类代码示例

本文整理汇总了Java中com.google.android.gms.awareness.snapshot.LocationResult的典型用法代码示例。如果您正苦于以下问题:Java LocationResult类的具体用法?Java LocationResult怎么用?Java LocationResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onMapReady

import com.google.android.gms.awareness.snapshot.LocationResult; //导入依赖的package包/类
@Override
public void onMapReady(final GoogleMap googleMap) {
    googleMap.getUiSettings().setAllGesturesEnabled(false);

    googleMap.setMaxZoomPreference(20.0f);
    googleMap.setMinZoomPreference(10.0f);
    final LatLng[] currentLocation = new LatLng[1];


    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        return;
    }
    Awareness.SnapshotApi.getLocation(awarenessApiClient)
            .setResultCallback(new ResultCallback<LocationResult>() {
                @Override
                public void onResult(@NonNull LocationResult locationResult) {
                    if (!locationResult.getStatus().isSuccess()) {
                        Log.e("", "Could not get location.");
                        return;
                    }
                    Location location = locationResult.getLocation();
                    currentLocation[0] = new LatLng(location.getLatitude(), location.getLongitude());
                    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLocation[0], 12.0f));
                    googleMap.animateCamera(CameraUpdateFactory.zoomTo(16.0f), 3000, null);
                }
            });
}
 
开发者ID:Pavou,项目名称:Stalker,代码行数:28,代码来源:MainActivity.java

示例2: getLocation

import com.google.android.gms.awareness.snapshot.LocationResult; //导入依赖的package包/类
/**
 * Get user's current location. We are also displaying Google Static map.
 */
@RequiresPermission("android.permission.ACCESS_FINE_LOCATION")
private void getLocation() {
    //noinspection MissingPermission
    Awareness.SnapshotApi.getLocation(mGoogleApiClient)
            .setResultCallback(new ResultCallback<LocationResult>() {
                @Override
                public void onResult(@NonNull LocationResult locationResult) {
                    if (!locationResult.getStatus().isSuccess()) {
                        Toast.makeText(SnapshotApiActivity.this, "Could not get location.", Toast.LENGTH_LONG).show();
                        return;
                    }

                    //get location
                    Location location = locationResult.getLocation();
                    ((TextView) findViewById(R.id.current_latlng)).setText(location.getLatitude() + ", " + location.getLongitude());

                    //display the time
                    TextView timeTv = (TextView) findViewById(R.id.latlng_time);
                    SimpleDateFormat sdf = new SimpleDateFormat("h:mm a dd-MM-yyyy", Locale.getDefault());
                    timeTv.setText("as on: " + sdf.format(new Date(location.getTime())));

                    //Load the current map image from Google map
                    String url = "https://maps.googleapis.com/maps/api/staticmap?center="
                            + location.getLatitude() + "," + location.getLongitude()
                            + "&zoom=20&size=400x250&key=" + getString(R.string.api_key);
                    Picasso.with(SnapshotApiActivity.this).load(url).into((ImageView) findViewById(R.id.current_map));
                }
            });
}
 
开发者ID:kevalpatel2106,项目名称:android-samples,代码行数:33,代码来源:SnapshotApiActivity.java

示例3: createRequest

import com.google.android.gms.awareness.snapshot.LocationResult; //导入依赖的package包/类
@Override
@RequiresPermission("android.permission.ACCESS_FINE_LOCATION")
protected PendingResult<LocationResult> createRequest(GoogleApiClient googleApiClient) {
    return Awareness.SnapshotApi.getLocation(googleApiClient);
}
 
开发者ID:Mauin,项目名称:ReactiveAwareness,代码行数:6,代码来源:LocationSingle.java

示例4: unwrap

import com.google.android.gms.awareness.snapshot.LocationResult; //导入依赖的package包/类
@Override
protected Location unwrap(LocationResult result) {
    return result.getLocation();
}
 
开发者ID:Mauin,项目名称:ReactiveAwareness,代码行数:5,代码来源:LocationSingle.java


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