After reading some posts related with this subject I cannot solve my doubt.
In my app, I log in with Facebook (Registration.class) and app starts in MainActivity.class .
In this class, I want to get some information about user like 'user_ID' to get image profile user and 'user_first_name', both are useful to put this information in the Navigation Drawer.
My problem is that I get this information in Registration.class with this code:
profileTracker = new ProfileTracker() {
@Override
protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) {
// App code
Log.i("PERFIL_NAME", Profile.getCurrentProfile().getFirstName());
Log.i("PERFIL_FOTO", Profile.getCurrentProfile().getProfilePictureUri(100, 100).toString());
Log.i("USER_ID", Profile.getCurrentProfile().getId());
}
};
but I do not know how I have to get it in MainActivity.class.
If I use this in the same way I get null. Also, I have tested with an Intent and it does not work because it is null too (I suppose that Intent is executed before than profileTracker()).
Moreover, I have tried some methods in MainActivity like:
public void putImageProfile() {
URL imgUrl = null;
try {
imgUrl = new URL("http://graph.facebook.com/'user_ID'/picture?type=large");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InputStream in = null;
try {
in = (InputStream) imgUrl.getContent();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Bitmap bitmap = BitmapFactory.decodeStream(in);
img_profile.setImageBitmap(bitmap); //ImageView in NavDrawer
}
('user_ID' is my user ID profile Facebook written manually 1000098...) and it does not work well.
In conclusion, I want to get 'user_ID' and 'user_name' in MainActivity.class ... and after, to get the image profile with the 'user_ID'.
Thank so much.