1
  • I am implementing in Android (Java).

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) {

                }
            }
        });
5agado
  • 2,444
  • 2
  • 21
  • 30
jclova
  • 5,466
  • 16
  • 52
  • 78

1 Answers1

1

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

Community
  • 1
  • 1
Lzh
  • 3,585
  • 1
  • 22
  • 36
  • 1
    True, I can check internet connection state. However, the connection can get lost anytime! As soon as it gets lost and the response returns an error, I want to know if it's no internet connection error or some other Facebook error. – jclova May 03 '13 at 15:40