This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mavenCentral() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<string name="facebook_app_id">383374132098267</string> | |
<string name="facebook_login_protocol_scheme">fb383374132098267</string> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
CallbackManager callbackManager; | |
TextView txtEmail, txtBirthday, txtFriends, txtLocation; | |
ProgressDialog mDialog; | |
ImageView imgAvatar; | |
@Override | |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
//printKeyHash(); | |
callbackManager = CallbackManager.Factory.create(); | |
txtBirthday = (TextView) findViewById(R.id.txt_birthday); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onSuccess(LoginResult loginResult) { | |
mDialog = new ProgressDialog(MainActivity.this); | |
mDialog.setMessage("Retrieving data..."); | |
mDialog.show(); | |
String accessToken = loginResult.getAccessToken().getToken(); | |
GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() { | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void getData(JSONObject object) { | |
try { | |
URL profile_picture | |
= new URL("https://graph.facebook.com/" | |
+ object.getString("id") | |
+ "/picture?width=250&height=250"); | |
Picasso.with(this).load(profile_picture.toString()).into(imgAvatar); | |
txtEmail.setText(object.getString("email")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
// If already login | |
if (AccessToken.getCurrentAccessToken() != null) { | |
//Just set User ID | |
GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() { | |
@Override | |
public void onCompleted(JSONObject object, GraphResponse response) { | |
getData(object); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<data android:scheme="@string/facebook_login_protocol_scheme" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id":"1336398453137452", | |
"email":"[email protected]", | |
"location": | |
{ | |
"id":"107677462599905", | |
"name":"Minsk, Belarus" | |
}, | |
"birthday":"04\/13\/1986", | |
"friends": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout ... | |
<LinearLayout ... | |
<Button | |
android:id="@+id/share_button" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_gravity="center_horizontal" | |
android:text="Share content" /> |