當前位置: 首頁>>代碼示例>>Java>>正文


Java Place.getName方法代碼示例

本文整理匯總了Java中com.google.android.gms.location.places.Place.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java Place.getName方法的具體用法?Java Place.getName怎麽用?Java Place.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.location.places.Place的用法示例。


在下文中一共展示了Place.getName方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: sendLocationDetails

import com.google.android.gms.location.places.Place; //導入方法依賴的package包/類
public static void sendLocationDetails(Context context, String ph_no, ContactItemDataModel contactData, Place place) {
	if (place != null) {
		double latitude = place.getLatLng().latitude;
		double longitude = place.getLatLng().longitude;
		String name = place.getName() == null ? "" : String.valueOf(place.getName());
		JsonObject location_message = new JsonObject();
		location_message.addProperty("latitude", latitude);
		location_message.addProperty("longitude", longitude);
		location_message.addProperty("name", name);
		SendMessageService.startSendTextMessage(context, ph_no,
				contactData.getContact_id(),
				location_message.toString(),
				"location", contactData.is_bot(), Utils.getCurrentTimestamp());
	}
}
 
開發者ID:arunrajora,項目名稱:Chit-Chat,代碼行數:16,代碼來源:MessageUtils.java

示例5: setPlace

import com.google.android.gms.location.places.Place; //導入方法依賴的package包/類
private void setPlace(Place place) {
    if (place == null) {
        this.place = null;
    } else {
        this.place = new LDPlace(place.getName() + "", place.getId(), place.getLatLng().latitude, place.getLatLng().longitude);
    }

    this.saveData();
}
 
開發者ID:micku7zu,項目名稱:Locate-driver,代碼行數:10,代碼來源:MainActivity.java

示例6: 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

示例7: onActivityResult

import com.google.android.gms.location.places.Place; //導入方法依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_PICK_LOCATION && resultCode == RESULT_OK) {
        if (data == null) {
            showError("Failed to pick location!");
            return;
        }
        Place place = PlacePicker.getPlace(data, this);
        String address = place.getAddress().toString();
        if (address.trim().isEmpty()) {
            showLoading();
            MapUtils.getAddress(place.getLatLng().latitude, place.getLatLng().longitude)
                    .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.NEW_THREAD))
                    .compose(bindToLifecycle())
                    .subscribe(s -> {
                        this.address = place.getName() + " - " + s;
                        location.setLatitude(place.getLatLng().latitude);
                        location.setLongitude(place.getLatLng().longitude);
                        locationText.setText(this.address);
                        dismissLoading();
                    }, throwable -> {
                        throwable.printStackTrace();
                        showError("Failed to get address!");
                        dismissLoading();
                    });
        } else {
            this.address = place.getName() + " - " + address;
            location.setLatitude(place.getLatLng().latitude);
            location.setLongitude(place.getLatLng().longitude);
            locationText.setText(this.address);
        }
    }
}
 
開發者ID:zetbaitsu,項目名稱:Sigap,代碼行數:35,代碼來源:RequestEscortActivity.java

示例8: onActivityResult

import com.google.android.gms.location.places.Place; //導入方法依賴的package包/類
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ACTIVITY_PICKPLACE && resultCode == Activity.RESULT_OK) {
        Place place = PlacePicker.getPlace(getActivity(), data);
        final CharSequence name = place.getName();
        LatLng ll = place.getLatLng();
        if (name == null || ll == null)
            return;

        // Build location
        final Location location = new Location("place");
        location.setLatitude(ll.latitude);
        location.setLongitude(ll.longitude);
        location.setTime(System.currentTimeMillis());

        // Get settings
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
        final boolean altitude_waypoint = prefs.getBoolean(PREF_ALTITUDE_WAYPOINT, DEFAULT_ALTITUDE_WAYPOINT);

        new AsyncTask<Object, Object, Object>() {
            protected Object doInBackground(Object... params) {
                int altitude_type = (location.hasAltitude() ? BackgroundService.ALTITUDE_GPS : BackgroundService.ALTITUDE_NONE);

                // Add elevation data
                if (!location.hasAltitude() && Util.isConnected(getActivity())) {
                    if (altitude_waypoint)
                        try {
                            GoogleElevationApi.getElevation(location, getActivity());
                            altitude_type = BackgroundService.ALTITUDE_LOOKUP;
                        } catch (Throwable ex) {
                            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                        }
                }

                if (altitude_type != BackgroundService.ALTITUDE_NONE)
                    altitude_type |= BackgroundService.ALTITUDE_KEEP;

                // Persist location
                new DatabaseHelper(getActivity()).insertLocation(location, altitude_type, name.toString()).close();
                return null;
            }

            @Override
            protected void onPostExecute(Object result) {
                if (running)
                    Toast.makeText(getActivity(), getString(R.string.msg_added, name.toString()), Toast.LENGTH_SHORT).show();
            }
        }.execute();

    } else if (requestCode == ACTIVITY_PLAY_SERVICES)
        ; // Do nothing

    else
        super.onActivityResult(requestCode, resultCode, data);
}
 
開發者ID:M66B,項目名稱:BackPackTrackII,代碼行數:56,代碼來源:SettingsFragment.java

示例9: 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.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。