我不知道如何获取结果,只有附近的公交车站。我试图 通过地点选择器文档寻求帮助。但它显示了附近的所有地方,如果我只需要公交车站该怎么办。它返回所有附近的地方如何只得到我想要的
import android.Manifest;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.location.Location;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.Toast;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlacePicker;
import com.google.android.gms.maps.model.LatLngBounds;
import transportation.lumiumdesign.com.transportation.R;
/**
*
* It contains a place picker to detect current location and nearby bus stops to it.
*/
public class CurrentLocMap extends FragmentActivity {
int PLACE_PICKER_REQUEST = 1;//Predefined req_code
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.current_loc_map);
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
/** Intent Builder will set current location of deviceif not provided
**/
try {
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}
//onActivityResult will launch place picker
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_PICKER_REQUEST) {
if (resultCode == RESULT_OK) {
Place place = PlacePicker.getPlace(this, data);
String toastMsg = String.format("Place: %s", place.getName());
Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
}
}
}
}