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


Java PlacePicker.getPlace方法代码示例

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


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

示例1: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(data, this);
            Intent intent = new Intent(this, InfoActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra("name", place.getName());
            intent.putExtra("lat", place.getLatLng().latitude);
            intent.putExtra("lng", place.getLatLng().longitude);
            startActivity(intent);
            finish();
        } else finish();
    }

}
 
开发者ID:hwhung0111,项目名称:2017NASA_NCTUBeach,代码行数:17,代码来源:LocationSelectActivity.java

示例2: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
/***
 * Called when the Place Picker Activity returns back with a selected place (or after canceling)
 *
 * @param requestCode The request code passed when calling startActivityForResult
 * @param resultCode  The result code specified by the second activity
 * @param data        The Intent that carries the result data.
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode==PLACE_PICKER_REQUEST&&resultCode==RESULT_OK){
        Place place = PlacePicker.getPlace(this,data);
        if (place==null){
            Log.i(LOG_TAG,"No place selected");
            return;
        }
        String placeName = place.getName().toString();
        String placeAddress = place.getAddress().toString();
        String placeId = place.getId();

        ContentValues values = new ContentValues();
        values.put(PlacesContract.PlaceEntry.COLUMN_PLACE_ID,placeId);
        getContentResolver().insert(PlacesContract.PlaceEntry.CONTENT_URI,values);
        refreshPlacesData();
    }
}
 
开发者ID:samagra14,项目名称:Shush,代码行数:27,代码来源:MainActivity.java

示例3: setCurrentLocation

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
/**
 * Set current location from map
 * TODO: Faire mieux la difference entre une location exacte et une
 *
 * @param location the location returned from the map picker
 */
public void setCurrentLocation(Intent data) {
  final Place place = PlacePicker.getPlace(getActivity(), data);
  Geocoder geocoder = new Geocoder(getActivity());

  try {
    List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
    elephant.currentLoc.cityName = addresses.get(0).getAddressLine(0);
    if (!addresses.get(0).getAddressLine(0).equals(addresses.get(0).getSubAdminArea())) {
      elephant.currentLoc.districtName = addresses.get(0).getSubAdminArea();
    }
    elephant.currentLoc.provinceName = addresses.get(0).getAdminArea();
  } catch (IOException e) {
    e.printStackTrace();
  }

  currentLocation.setText(elephant.currentLoc.format());
}
 
开发者ID:goutfeb,项目名称:ElephantAsia,代码行数:24,代码来源:AddProfilFragment.java

示例4: setBirthLocation

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
/**
 * Set birth location from map
 *
 * @param location the location returned from the map picker
 */
public void setBirthLocation(Intent data) {
  final Place place = PlacePicker.getPlace(getActivity(), data);
  Geocoder geocoder = new Geocoder(getActivity());

  try {
    List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
    elephant.birthLoc.cityName = addresses.get(0).getAddressLine(0);
    if (!addresses.get(0).getAddressLine(0).equals(addresses.get(0).getSubAdminArea())) {
      elephant.birthLoc.districtName = addresses.get(0).getSubAdminArea();
    }
    elephant.birthLoc.provinceName = addresses.get(0).getAdminArea();
  } catch (IOException e) {
    e.printStackTrace();
  }

  birthLocation.setText(elephant.birthLoc.format());
}
 
开发者ID:goutfeb,项目名称:ElephantAsia,代码行数:23,代码来源:AddProfilFragment.java

示例5: setRegistrationLocation

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
public void setRegistrationLocation(Intent data) {

    final Place place = PlacePicker.getPlace(getActivity(), data);
    Geocoder geocoder = new Geocoder(getActivity());

    try {
      List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
      elephant.registrationLoc.cityName = addresses.get(0).getAddressLine(0);
      if (!addresses.get(0).getAddressLine(0).equals(addresses.get(0).getSubAdminArea())) {
        elephant.registrationLoc.districtName = addresses.get(0).getSubAdminArea();
      }
      elephant.registrationLoc.provinceName = addresses.get(0).getAdminArea();
    } catch (IOException e) {
      e.printStackTrace();
    }

    registrationLocation.setText(elephant.registrationLoc.format());
  }
 
开发者ID:goutfeb,项目名称:ElephantAsia,代码行数:19,代码来源:AddRegistrationFragment.java

示例6: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_LOCATION) {
        final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);
        if (resultCode == Activity.RESULT_OK) {
            Toast.makeText(getApplicationContext(), R.string.location_enabled, Toast.LENGTH_LONG).show();
            startLocationUpdates();
        } else {
            Toast.makeText(getApplicationContext(), "Loc is still off,", Toast.LENGTH_LONG).show();
        }
    } else if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(data, this);
            double lat = place.getLatLng().latitude;
            double lon = place.getLatLng().longitude;
            setMyLocationToSharePref((float) lat, (float) lon);
            setMyAddress(this, place.getAddress().toString());
            Location newLoc = new Location("");
            newLoc.setLatitude(lat);
            newLoc.setLongitude(lon);
            EventBus.getDefault().post(newLoc);

        }
    }
}
 
开发者ID:shivarajp,项目名称:LivePokemonFinder,代码行数:26,代码来源:MainActivity.java

示例7: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
public void onActivityResult(final Activity activity, final int requestCode, final int resultCode, final Intent data) {
    if (mCallback == null || requestCode != REQUEST_PLACE_PICKER) {
        return;
    }
    response = Arguments.createMap();
    if (resultCode == 2) {
        response.putString("error", "Google Maps not setup correctly. Did you forget the API key, or enabling the Places API for Android?");
        mCallback.invoke(response);
    } else if (resultCode == Activity.RESULT_OK) {
        final Place place = PlacePicker.getPlace(data, reactContext);
        final CharSequence address = place.getAddress();
        final LatLng coordinate = place.getLatLng();
        final CharSequence name = place.getName();
        final CharSequence id = place.getId();
        response.putString("address", address.toString());
        response.putDouble("latitude", coordinate.latitude);
        response.putDouble("longitude", coordinate.longitude);
        response.putString("name", name.toString());
        response.putString("google_id", id.toString());
        mCallback.invoke(response);
    } else {
        response.putBoolean("didCancel", true);
        mCallback.invoke(response);
        return;
    }
}
 
开发者ID:zhangtaii,项目名称:react-native-google-place-picker,代码行数:27,代码来源:RNGooglePlacePickerModule.java

示例8: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode,
                                int resultCode, Intent data) {

    if (requestCode == PLACE_PICKER_REQUEST
            && resultCode == Activity.RESULT_OK) {

        final Place place = PlacePicker.getPlace(this, data);
        final CharSequence name = place.getName();
        final CharSequence address = place.getAddress();
        String attributions = (String) place.getAttributions();
        if (attributions == null) {
            attributions = "";
        }

        mName.setText(name);
        mAddress.setText(address);
        mAttributions.setText(Html.fromHtml(attributions));

    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:Truiton,项目名称:PlacePicker,代码行数:24,代码来源:PlacePickerActivity.java

示例9: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            place = PlacePicker.getPlace(this, data);
            String toastMsg = getString(R.string.location_set);
            Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
            Bid acceptedBid = myBook.getBid(bidPosition);
            acceptedBid.setLatitude(place.getLatLng().latitude);
            acceptedBid.setLongitude(place.getLatLng().longitude);
            myBook.deleteBids();
            myBook.setStatus(Book.Status.BORROWED);
            myBook.addBid(acceptedBid);
            ESController.EditBookTask editBookTask = new ESController.EditBookTask();
            editBookTask.execute(myBook);
            finish();
        }
    }
}
 
开发者ID:CMPUT301W16T12,项目名称:ProjectFive,代码行数:19,代码来源:BidsDisplayActivity.java

示例10: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(this, data);
            try
            {
                stationSelected = new Station(place);
                inputStation.setText(place.getName());
            }
            catch (IllegalArgumentException e)
            {
                String toastMsg = String.format("Ops, parece que %s não é um posto. Tente novamente.", place.getName());
                Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
            }
        }
    }
}
 
开发者ID:Gaso-UFS,项目名称:gaso,代码行数:18,代码来源:ExpensesRegisterActivity.java

示例11: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_PLACE_PICKER) {
        // This result is from the PlacePicker dialog.

        if (resultCode == Activity.RESULT_OK) {
            // retrieve latitude and longitude from result data
            final Place place = PlacePicker.getPlace(data, this);
            LatLng latLng = place.getLatLng();
            Log.i(TAG, "Lat: " + latLng.latitude + " Lon: " + latLng.longitude);

            onLocationPicked(latLng);
        }
    } else if (requestCode == REQUEST_RESOLVE_ERROR) {
        // This result is from the google play services error resolution intent

        resolvingError = false;
        if (resultCode == RESULT_OK) {
            Snackbar.make(snackbarCoordinator, R.string.resolution_successful,
                    Snackbar.LENGTH_LONG).show();
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:maciekjanusz,项目名称:compass-project,代码行数:26,代码来源:CompassActivity.java

示例12: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
/**
 * Retrieves the selected place from the place picker.
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            mPickedPlace = PlacePicker.getPlace(this, data);
        } else {
            mPickedPlace = null;
        }
        // Display the address of the selected place.
        CharSequence placeText = (mPickedPlace == null)
                ? getString(R.string.add_event_no_place_selected)
                : mPickedPlace.getAddress();
        ((TextView) findViewById(R.id.picked_place_address)).setText(placeText);
    }
}
 
开发者ID:sarahmaddox,项目名称:techcomm-map-android,代码行数:19,代码来源:AddEventActivity.java

示例13: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    // The user has selected a place. Extract the location
    if (requestCode == REQUEST_PLACE_PICKER && resultCode == Activity.RESULT_OK) {
        Place place = PlacePicker.getPlace(data, getActivity());
        Location l = new Location("placePicker");
        l.setLatitude(place.getLatLng().latitude);
        l.setLongitude(place.getLatLng().longitude);
        specifiedLocation = l;

        btn_join.setEnabled(true);
        //loadLocationLayout.setVisibility(View.VISIBLE);
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:AMOS-2015,项目名称:amos-ss15-proj2,代码行数:18,代码来源:JoinSearchFragment.java

示例14: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_PLACE_PICKER) {
        if (resultCode == Activity.RESULT_OK) {
            Place place = PlacePicker.getPlace(data, this);

            Map<String, Object> checkoutData = new HashMap<>();
            checkoutData.put("time", ServerValue.TIMESTAMP);

            mFirebase.child(FIREBASE_ROOT_NODE).child(place.getId()).setValue(checkoutData);

        } else if (resultCode == PlacePicker.RESULT_ERROR) {
            Toast.makeText(this, "Places API failure! Check the API is enabled for your key",
                    Toast.LENGTH_LONG).show();
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:googlesamples,项目名称:io2015-codelabs,代码行数:20,代码来源:MapsActivity.java

示例15: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入方法依赖的package包/类
@SuppressLint("CommitPrefEdits")
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_SIGNUP) {
        if(resultCode == RESULT_CANCELED){
            finish();
        }else{
            checkStartup();
        }
    }if (requestCode == REQUEST_TUTORIAL){
        m_preferences.edit().putBoolean(Constants.PREFERENCE_SHOWN_TUTORIAL,true).commit();
        checkStartup();
    } else if (requestCode == REQUEST_PLACE_PICKER) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(data, this);
            if(m_createFragment != null)
                m_createFragment.onPlacesSelected(new OnPlacesSelectedEvent(place,PlacePicker.getAttributions(data)));
           // m_eventBus.post(new OnPlacesSelectedEvent(place,PlacePicker.getAttributions(data)));
        }
    }
}
 
开发者ID:johncarpenter,项目名称:MarketAndroid,代码行数:22,代码来源:MainNavigationActivity.java


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