0

我目前正在尝试使用foursquare API 制作一个android 应用程序。我已经使用 GPS 成功检索了纬度和经度,但现在我似乎在返回带有这些坐标的场地列表时遇到了问题。我有客户端 ID 和客户端密码。谁能告诉我哪里出错了,因为这个 API 对我来说是陌生的。

代码:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    iv= (ImageView)findViewById(R.id.ivPictureReturned);
    ImageButton btn = (ImageButton)findViewById(R.id.ibCaptureImage);
    Button geotag = (Button)findViewById(R.id.bGeoTag);

    final LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    final LocationListener ll = new MyLocationListener();

    btn.setOnClickListener(new OnClickListener(){
        public void onClick(View v){
            Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(intent, 0);
        }
    });
    geotag.setOnClickListener(new OnClickListener(){
        public void onClick(View v){

            if(lm != null){
                lm.requestSingleUpdate(LocationManager.GPS_PROVIDER, ll, null);
            }else{
            // can't get the location
            }
        }
    });
}

public class MyLocationListener implements LocationListener
{

  @Override
  public void onLocationChanged(Location loc)
  {

      longitudeCoordinate = loc.getLongitude();
      latitudeCoordinate = loc.getLatitude();

    String Text = "My current location is: " +
    "Latitud = " + loc.getLatitude() +
    "Longitud = " + loc.getLongitude();
    Toast.makeText(getApplicationContext(), Text, Toast.LENGTH_LONG).show();
    try {
        Toast.makeText(getApplicationContext(), "phase 1", Toast.LENGTH_LONG).show();
        searchVenue(latitudeCoordinate,longitudeCoordinate);
    }catch (Exception e) {
        //Log.e("Error", "error getting venue", e);
        Toast.makeText(getApplicationContext(), error, Toast.LENGTH_SHORT).show();
    }
    //Toast.makeText( getApplicationContext(), Text, Toast.LENGTH_SHORT).show();

  }

  @Override
  public void onProviderDisabled(String provider)
  {
    Toast.makeText( getApplicationContext(), "Gps Disabled", Toast.LENGTH_SHORT ).show();
  }

  @Override
  public void onProviderEnabled(String provider)
  {
    Toast.makeText( getApplicationContext(), "Gps Enabled", Toast.LENGTH_SHORT).show();
  }

  @Override
  public void onStatusChanged(String provider, int status, Bundle extras)
  {

  }
}

public void searchVenue(double lat, double lng) throws FoursquareApiException{
    FoursquareApi foursquareapi = new FoursquareApi(client_Id, client_Secret, "findtapshop://connect");
    Result<VenuesSearchResult> result = foursquareapi.venuesSearch(lat+","+lng, null, null, null, null, null, null, null, null, null, null);

}
4

0 回答 0