I am working on android studio with firebase. I created login and signup activities. The user can also update there profile picture and display name.
On retrieving the user profile, I am getting the displayname, email, provider, UID and profile picture.
In emulator image shows in the imageview but when running it on real
device image doesnot appear.
I have also added setPersistanceEnabled(true) but it doesnot solve. I have pasted my code by which user profile is created and retrieved.
private void updateProfile(String uName, Uri uri) {
UserProfileChangeRequest userProfileChangeRequest = new
UserProfileChangeRequest.Builder()
.setDisplayName(uName)
.setPhotoUri(uri)
.build();
user.updateProfile(userProfileChangeRequest);
mRef.child("Name").setValue(uName);
mRef.child(uri.getLastPathSegment()).setValue(uri.toString());
StorageReference profileStorage =
mStorage.child(uri.getLastPathSegment());
profileStorage.putFile(uri);
showMessage("Upload Successful");
Intent intent = new Intent(this,UserHome.class);
startActivity(intent);
}else{
showMessage("Upload Profile Picture");
}
}
////// for retrieving and displaying ///////
String namee = user.getDisplayName();
Uri uri = mAuth.getCurrentUser().getPhotoUrl();
Glide.with(UserHome.this).load(uri).into(imageView);
textView.setText(user.getDisplayName());
Log.v("data",user.getPhotoUrl().toString());
When you update the user profile after selecting an image from phone storage it uses your phone's image URI and updates the user account with it. And it displays it for the first before closing or signing out because it is still in the cache. But when you reopen or login to that account that cache is cleared and it does not display that image. So, to overcome this issue you have to upload that image to firebase storage first then get the link of the image and update the current user's photo with that link. It will be a universal link and will be working even after you have reopened your app or re-login to your account.
Related
I'm working on a game with Unity and FB in this game I wanted to show user FB profile pic.
I am doing this
FB.API("/me/picture?redirect=false", HttpMethod.GET, GetFBPic);
private void GetFBPic(IGraphResult result)
{
if (string.IsNullOrEmpty(result.Error) && !result.Cancelled)
{
IDictionary data = result.ResultDictionary["data"] as IDictionary;
string url = data["url"] as string;
}
}
for getting FB profile pic but the url here gives the FB gaming pic not FB profile pic i.e FB DP
how can I get FB profile pic (DP) url.
enter image description here
I'm searching this from long time but not getting anything, Anyone please help me in this
but the url here gives the FB gaming pic not FB profile pic i.e FB DP how can I get FB profile pic (DP) url.
It is up to the user, whether they want to enter your app using their standard Facebook user profile, or a special gaming profile.
https://developers.facebook.com/docs/games/acquire/login-for-gaming#requesting-user-s-profile-picture:
If user chooses the Facebook Profile option, both gaming_profile and gaming_user_picture permissions will be granted to application.
GET graph.fb.gg/v7.0/me/picture // return profile picture
If user chooses the gaming name and avatar option, only gaming_profile permission will be granted to application.
GET graph.fb.gg/v7.0/me/picture // return avatar
I'm working on an Android version of an app that uses Facebook for authorization and for retrieving user's friend list.
As of SDK v.2.0, it became pretty hard to get list of friends that hadn't installed your app, but I made it work and now I need to get links to friends profile pictures (avatars). But Facebook does not want to return normal IDs for friends that haven't installed the app. For example, if a friend installed an app then FB returns its ID as digits, something like this 651651616851, and if not then FB returns string of chars like "glkjrgbdjrbgjdrbhgjhLFKBfEFbFkjgnrg".
If I use digit-like ID to retrieve photo, it works, but if I try to use charlike ID, FB returns an 803 error.My question is how do I get normal IDs or how to get friends profile pictures?
This is the API call to get the pictures of friends, you can specify a (minimum) width and height:
/me/friends?fields=picture.width(400).height(400)
Please follow the link of facebook sdk about the Track Current Profile.
FacebookSdk.sdkInitialize(this.getApplicationContext());
callbackManager = CallbackManager.Factory.create();
ProfileTracker profileTracker = new ProfileTracker() {
#Override
protected void onCurrentProfileChanged(
Profile oldProfile,
Profile currentProfile) {
// App code
Uri uri = currentProfile.getProfilePictureUri(200,200);
}
};
Now From Uri you can download the profile picture of user current profile.
I create app to Facebook with facebook-android-sdk:4.1.0
How to get all photo of logged in User?
I need to load user all photo
I use this code
I read this
I have to use Graph API
/* make the API call */
new Request(
session,
"/{photo-id}",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
}
}
).executeAsync();
please help
please explain
You can get everyone's Facebook profile picture using below.
You just call http://graph.facebook.com/USERNAME_OR_USERID/picture?type=large. This URL redirects you to image URL.
extention onto my answer:
how do I get the entire album?
You need https://graph.facebook.com/[uid]/albums?access_token=[AUTH_TOKEN] to get JSON array of all the albums of a user.
You will get three important things from here id - album id, name - album name, and type - album type.
What permissions do I need?
The permission required is user_photos see here
What is the best way to get ALL profile pictures from a given user?
Profile Pictures are under "Profile Pictures" album. To get to profile album, you need to look into albums array (as mentioned previously), iterate through the JSON result-set, until you get an album with name = Profile Pictures and type = profile. Get id of this object. This is the profile pictures album.
Now you can access it similar to you access any other album. That is, https://graph.facebook.com/[ALBUM_ID]/photos?access_token=[AUTH_TOKEN] this will list all the profile pictures of the user ever uploaded.
Hope this helps.
refer: http://developers.facebook.com/docs/reference/api/
In my camera app for Android i would like to share a photo taken by the user to the user's facebook wall. I would like it has:
a text description written by the user (like in a shareDialog)
the image taken with my camera app
the link to the image itself in the album (to swipe to the previously uploaded ones)
some text (caption+description) about my app
a link to my app (with icon?) in google play
Here's a picture of what i want: (tweet-to-facebook posts are very similar to this, so i think it can be done!)
How to achieve this?
Should i use Open Graph?
I tried following developers.facebook tutorials, but i failed!! i think samples are buggy! It's very frustrating...
Please help, i need someone to show me the right way!
EDIT
actually this is my code, no foto is shown:
private void shareWithFacebookOpenGraph(String pathToImage) {
Log.i("SHARE", "1. share with OpenGraph");
OpenGraphObject photo = OpenGraphObject.Factory.createForPost("myapp:photo");
photo.setProperty("title", "MyApp Photo");
photo.setProperty("image", "http://play.google.com/to_my_app_launcher_icon");
photo.setProperty("url", "http://play.google.com/to_my_app");
photo.setProperty("description", "Image taken with myApp for Android");
List<File> files = new ArrayList<File>();
files.add(new File(pathToImage));
OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
action.setProperty("photo", photo);
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(this, action, "myapp:take", "photo")
//.setImageAttachmentFilesForObject("image", files, true) // Error: image is not a property
//.setImageAttachmentFilesForAction(files, true) // Error sharing pictue: null
//.setImageAttachmentFilesForObject("photo", files, true) // can't create Collection (?!?!)
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
I have an android app that I show the contacts details include the contact profile image.
This is how I get the contact image:
Uri photo = null;
String sPhoto = cursor
.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_ID));
if (sPhoto != null) {
photo = Uri.withAppendedPath(person,ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
myImageView.setImageURI(photo);
This code works just fine when the image is taken from the phone, but in my phone (like many others) I have a facebook profile, twitter profile etc, and in my default dialer I can see the facebook or twitter profile image beside the contact name, or the normal image (from the phone)
My code is given me only the image that exists in my phone, How do I get all images include facebook or twitter if such images exists?
Thank you