Reputation: 1212
How can I programmatically check in using android application like foresquare ? question describes it well I am not sure if it is supported by facebook API
Upvotes: 0
Views: 1040
Reputation: 7439
Try with below method:
private ArrayList<String> permissions = new ArrayList<String>();
permissions.addAll(Arrays.asList("photo_upload","publish_checkins","publish_actions"));
Session session = openActiveSession(YOUR ACTIVITY NAME.this, true, new Session.StatusCallback() {
@SuppressLint("UseValueOf")
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
try {
if (getCurrentLocation() != null) {
location.put("latitude", new Double(YOUR LATITUDE));
location.put("longitude", new Double(YOUR LONGITUDE));
} else {
Toast.makeText(YOUR ACTIVITY NAME.this, getString(R.string.facebook_location_not_found), Toast.LENGTH_LONG).show();
return;
}
} catch (Exception e) {
e.printStackTrace();
}
Bundle params = new Bundle();
params.putString("place", id);
params.putString("coordinates", location.toString());
if (edtMessage.getText().toString().trim().length() > 0) {
params.putString("message", message);
}
Request.Callback callback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
Toast.makeText(YOUR ACTIVITY.this,"Checkins success, Toast.LENGTH_LONG).show();
}
};
Request request = new Request(session, "me/checkins", params, HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
}
}
}, permissions);
Upvotes: 1