简体   繁体   中英

Facebook Login in android with different devices

I am having a problem with using facebook login for android app. I am using Facebook sdk 3.0.1 for this. I am running on Samsung galaxy y and emulators it works fine. But on samsung note, intex aqua and nexus 5 it doesn't work. I tried building and cleaning the project again but still the problem persists. I am attaching the log of the intex aqua device:

08-09 11:01:56.850: W/com.facebook.Session(11390): Should not pass a read permission (offline_access) to a request for publish or manage authorization
08-09 11:01:56.850: W/com.facebook.Session(11390): Should not pass a read permission (email) to a request for publish or manage authorization
08-09 11:01:56.851: W/com.facebook.Session(11390): Should not pass a read permission (user_photos) to a request for publish or manage authorization
08-09 11:01:56.851: W/com.facebook.Session(11390): Should not pass a read permission (photo_upload) to a request for publish or manage authorization
08-09 11:01:56.851: W/com.facebook.Session(11390): Should not pass a read permission (read_stream) to a request for publish or manage authorization
08-09 11:02:32.603: W/Insideeee(11494): Insideeee
08-09 11:02:32.651: D/JpgDecHal(11494): JpgDecHal::JpgDecHal
08-09 11:02:32.651: D/JpgDecHal(11494): JpgDecHal::~JpgDecHal
08-09 11:02:32.652: D/JpgDecHal(11494): JpgDecHal::JpgDecHal
08-09 11:02:32.652: D/JpgDecHal(11494): JpgDecHal::start -> config jpeg path
08-09 11:02:32.652: D/JpgDecHal(11494): Decoder Src Addr:0x4501f008, width/height:[264, 65]           
08-09 11:02:32.652: D/JpgDecHal(11494): Decoder Dst Addr:0x45030000, width/height:[264, 65], format:3
08-09 11:02:32.653: D/JpgDecHal(11494): Decoder Dither:0, RangeDecode:0 [1868771184 1882089569 1702440557 1818456179]
08-09 11:02:32.654: D/JpgDecHal(11494): jpeg decoder result:0
08-09 11:02:32.655: D/JpgDecHal(11494): JpgDecHal::~JpgDecHal
08-09 11:02:32.682: D/JpgDecHal(11494): JpgDecHal::JpgDecHal
08-09 11:02:32.682: D/JpgDecHal(11494): JpgDecHal::~JpgDecHal
08-09 11:02:32.683: D/JpgDecHal(11494): JpgDecHal::JpgDecHal
08-09 11:02:32.683: D/JpgDecHal(11494): JpgDecHal::start -> config jpeg path
08-09 11:02:32.683: D/JpgDecHal(11494): Decoder Src Addr:0x4501f008, width/height:[144, 80]           
08-09 11:02:32.683: D/JpgDecHal(11494): Decoder Dst Addr:0x45032000, width/height:[144, 80], format:3
08-09 11:02:32.683: D/JpgDecHal(11494): Decoder Dither:0, RangeDecode:0 [0 0 0 0]
08-09 11:02:32.686: D/JpgDecHal(11494): jpeg decoder result:0
08-09 11:02:32.686: D/JpgDecHal(11494): JpgDecHal::~JpgDecHal

log for samsung note:

08-09 11:20:31.225: W/isSessionValid(14609): isSessionValidfalse
08-09 11:20:31.225: W/Button Clicked(14609): Button Clickedd
08-09 11:20:31.230: W/com.facebook.Session(14609): Should not pass a read permission (offline_access) to a request for publish or manage authorization
08-09 11:20:31.230: W/com.facebook.Session(14609): Should not pass a read permission (email) to a request for publish or manage authorization
08-09 11:20:31.230: W/com.facebook.Session(14609): Should not pass a read permission (user_photos) to a request for publish or manage authorization
08-09 11:20:31.230: W/com.facebook.Session(14609): Should not pass a read permission (photo_upload) to a request for publish or manage authorization
08-09 11:20:31.230: W/com.facebook.Session(14609): Should not pass a read permission (read_stream) to a request for publish or manage authorization
08-09 11:20:31.365: D/SensorManager(14609): unregisterListener:: Trklfufi 9 budiwrd5mrfo5WirfulblrwuFmfulTrklfufi$KfukwiFmfulTrklfufiRvht@,*f.,-+8
08-09 11:20:31.365: D/Sensors(14609): Remain listener = Sending .. normal delay 200ms
08-09 11:20:31.365: I/Sensors(14609): sendDelay --- 200000000
08-09 11:20:31.365: D/SensorManager(14609): JNI - sendDelay
08-09 11:20:31.370: I/SensorManager(14609): Set normal delay = true
08-09 11:20:41.315: D/SensorManager(14609): registerListener :: handle = 0  name= K3DH Acceleration Sensor delay= 200000 Trklfufi 9 budiwrd5mrfo5WirfulblrwuFmfulTrklfufi$KfukwiFmfulTrklfufiRvht@,*f.,-+8

EDIT:

Session session = Session.getActiveSession();
if(session.isOpened())
          {
              //some code
          }
          else
          {
              //some code
          }

Any help would be appreciable.

The problem i was the hash key that i have uploaded and that i got from the code below were different. That was the reason that when facebook app was installed on the device it did not get the logged in session of the user. Thus I wrote this code, got the hash, updated on my console and woo.. i got the login perfect. I am posting this so that my fellow developer save some time that i have spent in solving this problem.

try {
PackageInfo info = getPackageManager().getPackageInfo(
      "com.facebook.samples.loginhowto", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures){
       MessageDigest md = MessageDigest.getInstance("SHA");
       md.update(signature.toByteArray());
       Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM