I have implemented the Facebook login and it works fine on some devices/AVDs. My development device is a Gingerbread phone, but testing it with a 4.1.1 device, it simply does not log in. After pressing the facebook button, it shows a blank screen (trying to connect Facebook), and after 1-2 seconds it comes back to the home screen. Also, no errors are toasted or displayed in the Logcat. Oh, and the Facebook application is installed in the device... Any ideas?
UPDATE:
I enabled logging as suggested by Mark Venzke and using this procedure, and I got this warning (twice) on every login attempt (note: testing with a HTC One S phone):
07-05 20:14:50.582: W/PackageManager(605): Unable to load service info ResolveInfo{4171dbf0 com.htc.socialnetwork.facebook.remote.FacebookSyncService p=0 o=0 m=0x108000}
Note the com.htc.socialnetwork.facebook.remote.FacebookSyncService line, so is there any extra step needed for HTC devices?
Also, I'm attaching the code where the login is performed:
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
if (isResumed) {
FragmentManager manager = getSupportFragmentManager();
int backStackSize = manager.getBackStackEntryCount();
for (int i = 0; i < backStackSize; i++) {
manager.popBackStack();
}
com.facebook.Settings.addLoggingBehavior(LoggingBehavior.REQUESTS);
if (state.isOpened()) {
Bundle params = new Bundle();
params.putString("fields", "id");
params.putString("limit", "1");
Request request = new Request(Session.getActiveSession(), "me", params, HttpMethod.GET, new Callback()
{
@Override
public void onCompleted(Response response)
{
if (response != null)
{
Log.d("AuthGraphResponse", response.toString());
long id;
try {
id = response.getGraphObject().getInnerJSONObject().getLong("id");
app.setFacebookId(id);
Log.d("UserID", Long.valueOf(id).toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
showFragment(AUTH, false);
} else if (state.isClosed()) {
showFragment(UNAUTH, false);
}
}
}
UPDATE 2:
Is it possible that HTC renames the package name of the default Facebook application in all the devices (or some of them, whatever) to com.htc.socialnetwork.facebook (instead of com.facebook.katana) and it leads to this conflict? I don't really think that uninstalling the default app and installing Facebook from Google Play is an acceptable solution (also, I think default apps cannot be uninstalled).
UPDATE 3:
Not solved yet. 19 hours to award the 100 reputation bounty!
UPDATE 4:
Another interesting line of the LogCat:
07-15 10:55:51.718: E/chromium(30475): external/chromium/net/disk_cache/stat_hub.cc:216: [0715/105551:ERROR:stat_hub.cc(216)] StatHub::Init - App com.facebook.katana isn't supported.