Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook authorization trouble in Android
    primarykey
    data
    text
    <p>I am trying to integrate facebook with android mobile, all i need to do is to take some text from my application and put it as status on Facebook, i have tried facebook_sdk for the purpose, when i saw the debugging mode, the application is terminating at the line facebook.authorize(), though there is full internet connectivity in menifest... below is my code: Thanks in advance</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); button1 = (Button)findViewById(R.id.Button1); button2 = (Button)findViewById(R.id.Button2); tv1 = (TextView)findViewById(R.id.TextView1); et1 = (EditText)findViewById(R.id.EditText1); button1.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { b1Click(); } }); button2.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { b2Click(); } }); } private void saveFBToken(String token, long tokenExpires){ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.edit().putString("FacebookToken", token).commit(); } private void fbAuthAndPost(final String message){ facebook.authorize(this, new String[]{"publish_stream"},new DialogListener() { @Override public void onComplete(Bundle values) { Log.d(this.getClass().getName(),"Facebook.authorize Complete: "); saveFBToken(facebook.getAccessToken(), facebook.getAccessExpires()); updateStatus(values.getString(Facebook.TOKEN), message); } @Override public void onFacebookError(FacebookError error) { Log.d(this.getClass().getName(),"Facebook.authorize Error: "+error.toString()); } @Override public void onError(DialogError e) { Log.d(this.getClass().getName(),"Facebook.authorize DialogError: "+e.toString()); } @Override public void onCancel() { Log.d(this.getClass().getName(),"Facebook authorization canceled"); } }); } @Override protected void onActivityResult(int requestCode, int resultCode,Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode){ case Facebook.FORCE_DIALOG_AUTH: facebook.authorizeCallback(requestCode, resultCode, data); } } private void b1Click(){ mAuthAttempts = 0; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mFacebookToken = prefs.getString("FacebookToken", ""); if(mFacebookToken.equals("")){ fbAuthAndPost(et1.getText().toString()); }else{ updateStatus(mFacebookToken,et1.getText().toString()); } } private void b2Click(){ mAuthAttempts = 0; updateStatus(facebook.TOKEN,et1.getText().toString()); } public void updateStatus(String accessToken, String message){ try { Bundle bundle = new Bundle(); bundle.putString("message", message); bundle.putString(Facebook.TOKEN,accessToken); String response = facebook.request("me/feed",bundle,"POST"); Log.d("UPDATE RESPONSE",""+response); showToast("Update process complete. Respose:"+response); if(response.indexOf("OAuthException") &gt; -1){ if(mAuthAttempts==0){ mAuthAttempts++; fbAuthAndPost(message); }else{ showToast("OAuthException:"); } } } catch (MalformedURLException e) { Log.e("MALFORMED URL",""+e.getMessage()); showToast("MalformedURLException:"+e.getMessage()); } catch (IOException e) { Log.e("IOEX",""+e.getMessage()); showToast("IOException:"+e.getMessage()); } String s = facebook.getAccessToken()+"\n"; s += String.valueOf(facebook.getAccessExpires())+"\n"; s += "Now:"+String.valueOf(System.currentTimeMillis())+"\n"; tv1.setText(s); } private void showToast(String message){ Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload