Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>first create object and veriable for facebook:</p> <pre><code>private static String FACEBOOK_APP_ID = "492429660800628"; private Facebook facebook; private AsyncFacebookRunner mAsyncRunner; </code></pre> <p>after OnCreate Method :</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login_screen); facebook = new Facebook(FACEBOOK_APP_ID); mAsyncRunner = new AsyncFacebookRunner(facebook); loginFacebook();//this method when called when you required.. } private void loginFacebook() { if (!facebook.isSessionValid()) { facebook.authorize(this, new String[] { "email", "publish_stream", "read_stream" }, new LoginDialogListener()); } else { getProfileInformation(); } } class LoginDialogListener implements DialogListener { public void onComplete(Bundle values) { try { getProfileInformation(); } catch (Exception error) { Toast.makeText(LoginActivity.this, error.toString(), Toast.LENGTH_SHORT).show(); } } public void onFacebookError(FacebookError error) { Toast.makeText(LoginActivity.this, "Something went wrong. Please try again.", Toast.LENGTH_LONG).show(); } public void onError(DialogError error) { Toast.makeText(LoginActivity.this, "Something went wrong. Please try again.", Toast.LENGTH_LONG).show(); } public void onCancel() { Toast.makeText(LoginActivity.this, "Something went wrong. Please try again.", Toast.LENGTH_LONG).show(); } } </code></pre> <p>please try this method after login facebook:</p> <pre><code>public void getProfileInformation() { try { JSONObject profile = Util.parseJson(facebook.request("me")); Log.e("Profile", "" + profile); mUserId = profile.getString("id"); mUserToken = facebook.getAccessToken(); mUserName = profile.getString("name"); mUserEmail = profile.getString("email"); runOnUiThread(new Runnable() { public void run() { Log.e("FaceBook_Profile",""+mUserId+"\n"+mUserToken+"\n"+mUserName+"\n"+mUserEmail); Toast.makeText(getApplicationContext(), "Name: " + mUserName + "\nEmail: " + mUserEmail, Toast.LENGTH_LONG).show(); } }); } catch (FacebookError e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } </code></pre>
 

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