• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PlacePicker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PlacePicker类属于com.google.android.gms.location.places.ui包,在下文中一共展示了PlacePicker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: onWaypointTitleClick

import com.google.android.gms.location.places.ui.PlacePicker; //导入依赖的package包/类
@OnClick(R.id.reminder_item_waypoint_title_text_view)
public void onWaypointTitleClick() {
    PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
    if (mRemindItem.getWaypoint() != null) {
        LocationPoint locationPoint = mRemindItem.getWaypoint().getLocation();
        LatLng latLng = new LatLng(locationPoint.getLatitude(), locationPoint.getLongitude());
        LatLngBounds latLngBounds = new LatLngBounds(latLng, latLng);
        builder.setLatLngBounds(latLngBounds);
    }

    Intent intent = null;
    try {
        intent = builder.build(getActivity());
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
    }
    mProgressDialog = ProgressDialog.show(mContext,
            getString(R.string.reminder_place_picker_progress_dialog_title),
            getString(R.string.reminder_place_picker_progress_dialog_message), true, false);
    startActivityForResult(intent, PLACE_PICKER_REQUEST);
}
 
开发者ID:trigor74,项目名称:travelers-diary,代码行数:22,代码来源:ReminderItemFragment.java


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


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


示例9: onCreate

import com.google.android.gms.location.places.ui.PlacePicker; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_place_picker);
    mName = (TextView) findViewById(R.id.textView);
    mAddress = (TextView) findViewById(R.id.textView2);
    mAttributions = (TextView) findViewById(R.id.textView3);
    Button pickerButton = (Button) findViewById(R.id.pickerButton);
    pickerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                PlacePicker.IntentBuilder intentBuilder =
                        new PlacePicker.IntentBuilder();
                intentBuilder.setLatLngBounds(BOUNDS_MOUNTAIN_VIEW);
                Intent intent = intentBuilder.build(PlacePickerActivity.this);
                startActivityForResult(intent, PLACE_PICKER_REQUEST);

            } catch (GooglePlayServicesRepairableException
                    | GooglePlayServicesNotAvailableException e) {
                e.printStackTrace();
            }
        }
    });
}
 
开发者ID:Truiton,项目名称:PlacePicker,代码行数:26,代码来源:PlacePickerActivity.java


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


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


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


示例13: onPickEventPlaceClick

import com.google.android.gms.location.places.ui.PlacePicker; //导入依赖的package包/类
/**
 * Pick place
 * https://medium.com/@hitherejoe/exploring-play-services-place-picker-autocomplete-150809f739fe
 */
@Override
public void onPickEventPlaceClick() {
    PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
    if(editEventDataModel.getEvent().hasLocation()) {
        double longitude = editEventDataModel.getEvent().getLongitude();
        double latitude = editEventDataModel.getEvent().getLatitude();
        double offset = 0.01;
        LatLng southwest = new LatLng(latitude - offset, longitude - offset);
        LatLng northeast = new LatLng(latitude + offset, longitude + offset);
        intentBuilder.setLatLngBounds(new LatLngBounds(southwest, northeast));
    }
    try {
        startActivityForResult(intentBuilder.build(this), PLACE_PICKER_REQUEST_CODE);
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
        Toast.makeText(this, getString(R.string.unknown_error), Toast.LENGTH_LONG).show();
    }
}
 
开发者ID:LibertACAO,项目名称:libertacao-android,代码行数:23,代码来源:EditEventActivity.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) {
        // 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


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


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


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


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


示例19: 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 selectedPlace = PlacePicker.getPlace(data, this);
            savePlace(selectedPlace);
        }
    }
}
 
开发者ID:sathishmscict,项目名称:Pickr,代码行数:9,代码来源:MainActivity.java


示例20: onActivityResult

import com.google.android.gms.location.places.ui.PlacePicker; //导入依赖的package包/类
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    try {
        if (requestCode == REQUEST_CODE_PICKER && resultCode == RESULT_OK && data != null) {
            ArrayList<Image> dat = data.getParcelableArrayListExtra(ImagePickerActivity.INTENT_EXTRA_SELECTED_IMAGES);
            renderViewImage(dat);
        }
        else if (requestCode == PLACE_PICKER_REQUEST) {
            if (resultCode == RESULT_OK) {
                Place place = PlacePicker.getPlace(AddActivity.this, data);
                String placename = String.format("%s", place.getName());
                latitude = place.getLatLng().latitude;
                longitude = place.getLatLng().longitude;
                location_name.setText("" + placename);
                Toast.makeText(AddActivity.this, "You Select: " + placename, Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(this, "You Haven't Select Any Places", Toast.LENGTH_LONG).show();

            }
        }


    } catch (Exception e) {
        Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG).show();
        Log.d("Additem_Activity", "onActivityResult: " + e);
    }


}
 
开发者ID:Elbehiry,项目名称:Viajes,代码行数:29,代码来源:AddActivity.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TcpDiscoverySpi类代码示例发布时间:2022-05-21
下一篇:
Java Murmur3Partitioner类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap