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


Java Place.getAddress方法代码示例

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


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

示例1: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的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

示例2: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的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

示例3: displayPlace

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
private void displayPlace( Place place ) {
    if( place == null )
        return;

    String content = "";
    if( !TextUtils.isEmpty( place.getName() ) ) {
        content += "Name: " + place.getName() + "\n";
    }
    if( !TextUtils.isEmpty( place.getAddress() ) ) {
        content += "Address: " + place.getAddress() + "\n";
    }
    if( !TextUtils.isEmpty( place.getPhoneNumber() ) ) {
        content += "Phone: " + place.getPhoneNumber();
    }

    mTextView.setText( content );
}
 
开发者ID:Lakkichand,项目名称:AndroidDemoProjects,代码行数:18,代码来源:MainActivity.java

示例4: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) { 
        if (requestCode == REQUEST_CODE_CAMERA) { // capture new image
            if (cameraFile != null && cameraFile.exists())
                sendImageMessage(cameraFile.getAbsolutePath());
        } else if (requestCode == REQUEST_CODE_LOCAL) { // send local image
            if (data != null) {
                Uri selectedImage = data.getData();
                if (selectedImage != null) {
                    sendPicByUri(selectedImage);
                }
            }
        } else if (requestCode == REQUEST_CODE_MAP) { // location
            final Place place = PlacePicker.getPlace(data, getActivity());
            double latitude = place.getLatLng().latitude;
            double longitude = place.getLatLng().longitude;
            String locationAddress = (String) place.getAddress();

            if (locationAddress != null && !locationAddress.equals("")) {
                sendLocationMessage(latitude, longitude, locationAddress);
            } else {
                Toast.makeText(getActivity(), R.string.unable_to_get_loaction, Toast.LENGTH_SHORT).show();
            }
            
        }
    }
}
 
开发者ID:HyphenateInc,项目名称:Hyphenate-EaseUI-Android,代码行数:30,代码来源:EaseChatFragment.java

示例5: onActivityResult

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

            LatLng latLng = place.getLatLng();
            if(latLng != null) {
                editEventDataModel.getEvent().setLatitude(latLng.latitude);
                editEventDataModel.getEvent().setLongitude(latLng.longitude);
            }
            if(place.getName() != null) {
                editEventDataModel.getEvent().setLocationSummary(place.getName().toString());
            }
            if(place.getAddress() != null) {
                editEventDataModel.getEvent().setLocationDescription(place.getAddress().toString());
            }
            if(place.getWebsiteUri() != null) {
                editEventDataModel.getEvent().setLinkUrl(place.getWebsiteUri().toString());
                editEventDataModel.getEvent().setLinkText(getString(R.string.linkTextDefaultPlaceURL));
            }
            editEventDataModel.notifyChange();
        }
    } else {
        String filePath = ImageUtils.onActivityResult(this, requestCode, resultCode, data);
        if (filePath != null) {
            editEventDataModel.setEventLocalImage(filePath);
            Toast.makeText(this, getString(R.string.photoSelectedSuccessfully), Toast.LENGTH_SHORT).show();
        }
    }
}
 
开发者ID:LibertACAO,项目名称:libertacao-android,代码行数:32,代码来源:EditEventActivity.java

示例6: onActivityResult

import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
/**
 * Extracts data from PlacePicker result.
 * This method is called when an Intent has been started by calling
 * {@link #startActivityForResult(android.content.Intent, int)}. The Intent for the
 * {@link com.google.android.gms.location.places.ui.PlacePicker} is started with
 * {@link #REQUEST_PLACE_PICKER} request code. When a result with this request code is received
 * in this method, its data is extracted by converting the Intent data to a {@link Place}
 * through the
 * {@link com.google.android.gms.location.places.ui.PlacePicker#getPlace(android.content.Intent,
 * android.content.Context)} call.
 *
 * @param requestCode
 * @param resultCode
 * @param data
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // BEGIN_INCLUDE(activity_result)
    if (requestCode == REQUEST_PLACE_PICKER) {
        // This result is from the PlacePicker dialog.

        // Enable the picker option
        showPickAction(true);

        if (resultCode == Activity.RESULT_OK) {
            /* User has picked a place, extract data.
               Data is extracted from the returned intent by retrieving a Place object from
               the PlacePicker.
             */
            final Place place = PlacePicker.getPlace(data, getActivity());

            /* A Place object contains details about that place, such as its name, address
            and phone number. Extract the name, address, phone number, place ID and place types.
             */
            final CharSequence name = place.getName();
            final CharSequence address = place.getAddress();
            final CharSequence phone = place.getPhoneNumber();
            final String placeId = place.getId();
            String attribution = PlacePicker.getAttributions(data);
            if(attribution == null){
                attribution = "";
            }

            // Update data on card.
            getCardStream().getCard(CARD_DETAIL)
                    .setTitle(name.toString())
                    .setDescription(getString(R.string.detail_text, placeId, address, phone,
                            attribution));

            // Print data to debug log
            Log.d(TAG, "Place selected: " + placeId + " (" + name.toString() + ")");

            // Show the card.
            getCardStream().showCard(CARD_DETAIL);

        } else {
            // User has not selected a place, hide the card.
            getCardStream().hideCard(CARD_DETAIL);
        }

    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
    // END_INCLUDE(activity_result)
}
 
开发者ID:googlesamples,项目名称:android-play-places,代码行数:66,代码来源:PlacePickerFragment.java


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