Here is my code for sending a request on facebook:
Bundle params = new Bundle();
params.putString("message", "I just smashed friends! Can you beat it?");
showDialogWithoutNotificationBar("apprequests", params);
WebDialog requestsDialog = new WebDialog.RequestsDialogBuilder(sessionContext, Session.getActiveSession(), params))
.setOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(Bundle values, FacebookException error) {
if (error != null) {
if (error instanceof FacebookOperationCanceledException) {
Log.v("message", "Request cancelled");
} else {
Log.v("message", "Netwrok error");
}
} else {
final String requestId = values.getString("request");
if (requestId != null) {
Log.v("message", "Request sent");
} else {
Log.v("message", "Request cancelled");
}
}
}
})
.build();
requestsDialog.show();
Whenever I call this function I get the following errors:
“Can’t create handler inside thread that has not called Looper.prepare()”
I looked at all the facebook examples and all of them give me the same error. I’ve tried to add Looper.prepare() and Looper.loop() to the code but it crashes.
I’m clueless on what to do over here. Any clues would be very appreciated.
Thanks