android – 如何通过PlaceType过滤Place Picker的结果?

前端之家收集整理的这篇文章主要介绍了android – 如何通过PlaceType过滤Place Picker的结果?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
目前,地点选择器显示地图上标有所有地点的地图.地点列表位于屏幕底部.

如果我按地点类型过滤地点会很棒.

例如,地图和列表仅显示附近的出租车站.

我的java代码

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.widget.Toast;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlacePicker;


public class PlacesAPIActivity extends AppCompatActivity {

    private int PLACE_PICKER_REQUEST = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_places_api);

                PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
                Intent intent;
                try {
                    intent = builder.build(getApplicationContext());
                    startActivityForResult(intent,PLACE_PICKER_REQUEST);
                } catch (GooglePlayServicesRepairableException e) {
                    e.printStackTrace();
                } catch (GooglePlayServicesNotAvailableException e) {
                    e.printStackTrace();
                }

            }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_place_api,menu);

        return true;
    }

    protected void onActivityResult(int requestCode,int resultCode,Intent data) {
        if (requestCode == PLACE_PICKER_REQUEST) {
            if (resultCode == RESULT_OK) {

                Place place = PlacePicker.getPlace(data,this) ;

                String toastMsg = String.format("Place: %s %s",place.getName(),place.getPhoneNumber());
                Toast.makeText(this,toastMsg,Toast.LENGTH_LONG).show();
            }
        }
    }

}

我的XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:background="@drawable/bg_gradient">

解决方法

功能目前无法使用.您可以按照这些未解决的问题进行更新:

Issue 8484: Filter Place Picker by PlaceType

猜你在找的Android相关文章