java - Facebook login not working with signed application -
i using following code login facebook. login process works while debugging, not work signed application. have added both debug hash key , release hash key in facebook app settings without success. idea causing this?
package com.priyank.safeboard; import java.util.arrays; import android.content.intent; import android.os.bundle; import android.util.log; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.button; import com.actionbarsherlock.app.sherlockfragment; import com.facebook.session; import com.facebook.sessionstate; import com.facebook.uilifecyclehelper; import com.facebook.widget.loginbutton; public class mainfragment extends sherlockfragment { private static final string tag = "mainfragment"; private uilifecyclehelper uihelper; button b; loginbutton authbutton; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.safeboardlogin, container, false); authbutton = (loginbutton) view.findviewbyid(r.id.authbutton); authbutton.setfragment(this); /*b=(button) view.findviewbyid(r.id.button1); b.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { updatedetail(); } });*/ authbutton.setreadpermissions(arrays.aslist("user_location", "user_birthday","user_likes", "user_status")); return view; } protected void updatedetail() { intent intent = new intent(); intent.setclass(getactivity(), mainactivity.class); startactivity(intent); } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); uihelper = new uilifecyclehelper(getactivity(), callback); uihelper.oncreate(savedinstancestate); } @override public void onresume() { super.onresume(); session session = session.getactivesession(); if (session != null && session.isopened() || session.isclosed() ) { onsessionstatechange(session, session.getstate(), null); } uihelper.onresume(); } @override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); uihelper.onactivityresult(requestcode, resultcode, data); } @override public void onpause() { super.onpause(); uihelper.onpause(); } @override public void ondestroy() { super.ondestroy(); uihelper.ondestroy(); } @override public void onsaveinstancestate(bundle outstate) { super.onsaveinstancestate(outstate); uihelper.onsaveinstancestate(outstate); } private void onsessionstatechange(session session, sessionstate state, exception exception) { if (state.isopened()) { updatedetail(); authbutton.setvisibility(view.invisible); //b.setvisibility(view.visible); log.i(tag, "logged in..."); } else if (state.isclosed()) { log.i(tag, "logged out..."); } } private session.statuscallback callback = new session.statuscallback() { @override public void call(session session, sessionstate state, exception exception) { onsessionstatechange(session, state, exception); } }; }
i have used following code obtain key hash app while debugging app in log cat how obtain "key hash" signed app?
try { packageinfo info = getpackagemanager().getpackageinfo( "your package name", packagemanager.get_signatures); (signature signature : info.signatures) { messagedigest md = messagedigest.getinstance("sha"); md.update(signature.tobytearray()); log.d("your tag", base64.encodetostring(md.digest(), base64.default)); } } catch (namenotfoundexception e) { } catch (nosuchalgorithmexception e) { }
the thing changing iz application signature, it's obvious there hash. facebook gives wrong method hash calculating on pages. today had problem - solution: generating hash key app using facebook sdk works ok me.
Comments
Post a Comment