android - problems with Request.executeMeRequestAsync(session, Request.GraphUserCallback()) function -
i'm following tutorial login on android application using facebook.
i've had many problems hash keys , , think i've solve them all, because session gets opened
state.
the problem i'm having after log in facebook, when session opened, code executes request.executemerquestasync()
, never enters oncomplete()
part... idea?
here code...
package com.example.firstandroidapp; import java.security.messagedigest; import java.security.nosuchalgorithmexception; import android.app.activity; import android.content.intent; import android.content.pm.packageinfo; import android.content.pm.packagemanager; import android.content.pm.packagemanager.namenotfoundexception; import android.content.pm.signature; import android.os.bundle; import android.util.base64; import android.util.log; import android.widget.textview; import com.facebook.request; import com.facebook.response; import com.facebook.session; import com.facebook.sessionstate; import com.facebook.model.graphuser; public class mainactivity extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // start facebook login session.openactivesession(this, true, new session.statuscallback() { // callback when session changes state @override public void call(session session, sessionstate state, exception exception) { try { packageinfo info = getpackagemanager().getpackageinfo("com.example.firstandroidapp", packagemanager.get_signatures); (signature signature : info.signatures) { messagedigest md = messagedigest.getinstance("sha"); md.update(signature.tobytearray()); log.i("digest: ", base64.encodetostring(md.digest(), 0)); } } catch (namenotfoundexception e) { log.e("test", e.getmessage()); } catch (nosuchalgorithmexception e) { log.e("test", e.getmessage()); } if (session.isopened()) { // make request /me api request.executemerequestasync(session, new request.graphusercallback() { // callback after graph api response user object @override public void oncompleted(graphuser user, response response) { // never gets here... if (user != null) { textview welcome = (textview) findviewbyid(r.id.welcome); welcome.settext("hello " + user.getname() + "!"); } } }); } } }); } @override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); session.getactivesession().onactivityresult(this, requestcode, resultcode, data); } }
thanx in advance. david.
i had same problem.
the tutorial tells modify androidmanifest.xml. in modification put tags below in wrong places (i didn't use eclipse modify manifest file) , prevented callback.
<manifest ...> ... <application ...> ... <activity android:name="com.facebook.loginactivity"/> ... <meta-data android:name="com.facebook.sdk.applicationid" android:value="@string/app_id"/> ... </application> ... <uses-permission android:name="android.permission.internet"/> ... </manifest>
try double-check androidmanifest.xml. the official document helpful.