android - Post to user facebook wall not working when Facebook app is installed on device/emulator -


i've built activity uses this implementation (see accepted answer) post status update on user's facebook wall.

it works no problem if emulator/phone not have facebook app installed.

if emulator/phone has facebook app installed, facebook app loads login screen, after trying login, facebook app disappears bringing me app.

has had experience when facebook app installed?

my code:

public class achievementactivity extends activity implements dialoglistener, onclicklistener{   private facebook facebook; button facebookpostbutton; string defaultfacebookpost;  @override public void oncreate(bundle savedinstancestate){     super.oncreate(savedinstancestate);      requestwindowfeature(window.feature_custom_title);     setcontentview(r.layout.achievements);     getwindow().setfeatureint(window.feature_custom_title, r.layout.custom_title_layout);      view achievementdivider = (view)findviewbyid(r.id.achievementdivider);     int[] colors = {0, 0xff00ffff, 0};     achievementdivider.setbackgrounddrawable(new gradientdrawable(orientation.right_left, colors));      //get title of achievement intent started activity activity statisticsactivity     string achievementtitlestring = getintent().getstringextra("title");      string achievementtexttodisplay = getachievementtexttodisplay(achievementtitlestring);      defaultfacebookpost = getdefaultpost(achievementtitlestring);      //imageview achievementactivityachievementbadgeimageview = (imageview)findviewbyid(r.id.achievementactivityachievementbadgeimageview);     textview achievementactivitybadgetitletextview = (textview)findviewbyid(r.id.achievementactivitybadgetitletextview);         achievementactivitybadgetitletextview.settext(achievementtitlestring);      textview achievementactivityachievementtext = (textview)findviewbyid(r.id.achievementactivityachievementtext);         achievementactivityachievementtext.settext(achievementtexttodisplay);      facebookpostbutton = (button)findviewbyid(r.id.facebookpostbutton);     facebookpostbutton.setonclicklistener(this);   }  @override public void oncomplete(bundle values) {      if (values.isempty())     {         toast.maketext(getapplicationcontext(), "empty", toast.length_short);          return;     }      if (!values.containskey("post_id"))     {         try         {             bundle parameters = new bundle();             parameters.putstring("message", defaultfacebookpost);// message post wall             facebook.dialog(achievementactivity.this, "stream.publish", parameters, this);// "stream.publish" api call         }         catch (exception e)         {             // todo: handle exception                 system.out.println(e.getmessage());         }     }      try      {         facebook.logout(getapplicationcontext());     }      catch (malformedurlexception e)      {         // todo auto-generated catch block         e.printstacktrace();     }      catch (ioexception e)      {         // todo auto-generated catch block         e.printstacktrace();     } }  @override public void onfacebookerror(facebookerror error)  {     toast.maketext(achievementactivity.this, "onfacebookerror", toast.length_long);  }  @override public void onerror(dialogerror e)  {     toast.maketext(achievementactivity.this, "onerror", toast.length_long);  }  @override public void oncancel()  {     toast.maketext(achievementactivity.this, "oncancel", toast.length_long); }  @override public void onclick(view v) {     if (v == facebookpostbutton)     {         facebook = new facebook("my_facebook_api");         // replace app_api_id own         facebook.authorize(this, new string[] {"publish_stream", "read_stream", "offline_access"}, this);      } }  private string getdefaultpost(string defaulttitlestring)  {     //do stuff here string post wall      return defaultpost; }  private string getachievementtexttodisplay(string achievementtitlestring) {     string achievementtexttodisplay = "default";      //do stuff here text display in activity             //this has nothing facebook post...      return achievementtexttodisplay; }  } 

logcat telling me this:

05-11 13:03:34.076: info/activitymanager(98): starting activity: intent { cmp=com.facebook.katana/.proxyauth (has extras) } 05-11 13:03:34.246: info/activitymanager(98): displayed activity com.facebook.katana/.proxyauth: 158 ms (total 158 ms) 05-11 13:03:35.166: debug/dalvikvm(12390): gc_for_malloc freed 6729 objects / 418424 bytes in 44ms 05-11 13:03:35.166: debug/webviewglue(12390): nativedestroy view: 0x527e20 05-11 13:03:35.166: debug/nativecrypto(12390): freeing openssl session 

edit : after having install android development platform on multiple machines on past year , having issue facebook after creating new development environments, have found simple answer can cause facebook implementation working on 1 device , not another....

the secret facebook api key (the 1 list on developer.facebook.com) different each version of app package different certificate. example, have 2 development machines. since both of these machines build applications different certificates, must ensure generate facebook api secret key each machine , list them @ developer.facebook.com.

it because when logged in facebook account login session created in device. have logout facebook after doing task.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -