简体   繁体   English

自定义谷歌地点以查找附近的餐馆

[英]Customize google places to find restaurants nearby

I am building an android app to find all the restaurant nearby. 我正在构建一个Android应用程序来查找附近的所有餐厅。 im taking the help of google places api to do so but i am not able to customize it to shown only restaurants. 即时通过google places api的帮助这样做,但我无法自定义它只显示餐馆。 So please help and thanks in advance. 所以请提前帮助和感谢。

public class MainActivity extends FragmentActivity
    implements OnConnectionFailedListener {
private GoogleApiClient mGoogleApiClient;
Button btn; 

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    btn = (Button) findViewById(R.id.button);


    mGoogleApiClient = new GoogleApiClient
            .Builder(this)
            .addApi(Places.GEO_DATA_API)
            .addApi(Places.PLACE_DETECTION_API)
            .enableAutoManage(this, this)
            .build();

   PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
            .getCurrentPlace(mGoogleApiClient, null);
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {

                                   Toast.makeText(MainActivity.this, "Place   " + placeLikelihood.getPlace().getName(), Toast.LENGTH_LONG).show();

            }

            likelyPlaces.release();
        }
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM