大佬教程收集整理的这篇文章主要介绍了android – 如何通过PlaceType过滤Place Picker的结果?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
如果我按地点类型过滤地点会很棒.
例如,地图和列表仅显示附近的出租车站.
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://scheR_452_11845@as.android.com/apk/res/android" xmlns:tools="http://scheR_452_11845@as.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:BACkground="@drawable/bg_gradient">
以上是大佬教程为你收集整理的android – 如何通过PlaceType过滤Place Picker的结果?全部内容,希望文章能够帮你解决android – 如何通过PlaceType过滤Place Picker的结果?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。