2014-04-13 83 views
0

我想在android中更新用戶的位置以及用戶的位置。我有緯度,經度和位置的名稱。 我已經更新狀態,但無法弄清楚如何將它與位置一起發佈。android:如何在facebook上發佈狀態

Session session = Session.getActiveSession(); 

      Request.Callback callback = new Request.Callback() { 

       @Override 
       public void onCompleted(Response response) { 

        Log.d("Checkin", response.toString()); 
        Toast.makeText(context, response.toString(), 
          Toast.LENGTH_LONG).show(); 
       } 
      }; 
      if (session != null && session.isOpened()) { 
       Request.newStatusUpdateRequest(session, 
         "Posting from my fyp", null, null, callback) 
         .executeAsync(); 
      } 

回答

0

我們可以做到這一點使用Facebook的最新SDK:

Location location = new Location("provider"); 
location.setLatitude(13.1234); 
location.setLongitude(13.1234); 

final Session session = Session.getActiveSession(); 
Request placesSearchRequest = Request.newPlacesSearchRequest(session, location, 100, 
     1, "", 
     new GraphPlaceListCallback() { 

     @Override 
     public void onCompleted(List<GraphPlace> places, Response response) { 
      Request statusUpdateRequest = Request.newStatusUpdateRequest(session, "Hell Yea :P #fyp #success #viaCheckinApp", 
          places.get(0), null, new Callback() { 

           @Override 
           public void onCompleted(Response response) { 
            debug("response of posting checkin to facebook: " + response.toString());        
           } 
          }); 
        statusUpdateRequest.executeAsync(); 
       } 
      }); 

    placesSearchRequest.executeAsync(); 
相關問題