Android 如何从谷歌地图搜索活动中获取企业地址
我正在尝试从我的应用程序启动Google地图的搜索活动,以从用户选择的位置获取地址。我可以按照谷歌的指导方针启动搜索活动,但我很难弄清楚如何为结果启动搜索活动(在本例中,用户选择位置作为地址) 从屏幕下方,用户可以选择“Peet's Coffee&Tea”,因为她的位置和控件应返回到我的应用程序及其地址。Android 如何从谷歌地图搜索活动中获取企业地址,android,google-maps,android-intent,google-maps-api-3,Android,Google Maps,Android Intent,Google Maps Api 3,我正在尝试从我的应用程序启动Google地图的搜索活动,以从用户选择的位置获取地址。我可以按照谷歌的指导方针启动搜索活动,但我很难弄清楚如何为结果启动搜索活动(在本例中,用户选择位置作为地址) 从屏幕下方,用户可以选择“Peet's Coffee&Tea”,因为她的位置和控件应返回到我的应用程序及其地址。 感谢您的时间,我可以通过使用Google PlacePicker API来实现这一点 try { PlacePicker.IntentBuilder intentBu
感谢您的时间,我可以通过使用Google PlacePicker API来实现这一点
try
{
PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
Intent intent = intentBuilder.build(getActivity());
// Start the Intent by requesting a result, identified by a request code.
startActivityForResult(intent, ET_PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException e)
{
GooglePlayServicesUtil
.getErrorDialog(e.getConnectionStatusCode(), getActivity(), 0);
} catch (GooglePlayServicesNotAvailableException e)
{
Toast.makeText(getActivity(), "Google Play Services is not available.",
Toast.LENGTH_LONG)
.show();
}
在ActivityResult()中
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == ET_PLACE_PICKER_REQUEST)
{
if (resultCode == Activity.RESULT_OK)
{
final Place place = PlacePicker.getPlace(getContext(), data);
final CharSequence name = place.getName();
final CharSequence address = place.getAddress();
final String placeId = place.getId();
//Your Code
}
}}