facebook - Why i am lose my Access Token in android? -
i working on facebook application in android.i running application 1 r 2 times access token works after third time loss access token.why,i lose access token?what can without lose of access token when run.
any 1 please me....
edit 1 :
protected void onactivityresult(int requestcode, int resultcode, intent data) { // todo auto-generated method stub super.onactivityresult(requestcode, resultcode, data); mfacebook.authorizecallback(requestcode, resultcode, data); }
login button click::::
mbtnfblogin.setonclicklistener(new view.onclicklistener() {
@override public void onclick(view v) { log.d("image button", "button clicked"); logintofacebook(); } });
login method ::::::
public void logintofacebook() {
mprefs = getpreferences(mode_private); string access_token = mprefs.getstring("access_token", null); long expires = mprefs.getlong("access_expires", 0); if (access_token != null) { mfacebook.setaccesstoken(access_token); log.d("fb sessions", "" + mfacebook.issessionvalid()); toast.maketext(getapplicationcontext(), "login successfully", toast.length_long).show(); } if (expires != 0) { mfacebook.setaccessexpires(expires); } if (!mfacebook.issessionvalid()) { mfacebook.authorize(this, new string[] { "email", "publish_stream" }, new dialoglistener() { @override public void oncancel() { // function handle cancel event log.d("fb sessions", "" + mfacebook.issessionvalid()); toast.maketext(getapplicationcontext(), "login cancel", toast.length_long).show(); } @override public void oncomplete(bundle values) { // function handle complete event // edit preferences , update facebook acess_token sharedpreferences.editor editor = mprefs.edit(); editor.putstring("access_token", mfacebook.getaccesstoken()); editor.putlong("access_expires", mfacebook.getaccessexpires()); editor.commit(); log.d("fb sessions", "" + mfacebook.issessionvalid()); toast.maketext(getapplicationcontext(), "login successfully", toast.length_long) .show(); } @override public void onerror(dialogerror error) { // function handle error } @override public void onfacebookerror(facebookerror fberror) { // function handle facebook errors } }); } }
access token expires every hour may running third time after hour
Comments
Post a Comment