Reputation: 5576
I want to throw an appropriate error message when cannot connect to the server. (Either the server is down or there is no internet connection.)
It seems when there's no internet connection, it returns with a response with FacebookRequestError of errorCode = -1 & requestCode = -1. Is this safe to think only no internet connection throws this error? In other words, are there other errors that throws errorCode = -1 & requestCode = -1?
Request request = new Request(session, "me/friends", params, HttpMethod.GET, new Request.Callback() {
@Override
public void onCompleted(Response response) {
try {
FacebookRequestError fre = response.getError();
if(fre != null) {
int errorCode = fre.getErrorCode();
int requestCode = fre.getRequestStatusCode();
if(errorCode == -1 && requestCode == -1) {
// probably no internet connection
}
}
} catch(Exception e) {
}
}
});
Upvotes: 1
Views: 1313
Reputation: 3635
This is not specific to the Facebook APIs. Check this question for an answer:
Detect whether there is an Internet connection available on Android
I think this is a duplicate question
Upvotes: 1