vendredi 17 avril 2015

How to load Facebook cover photo via graphRequest with a higher resolution? [Android | Facebook v2.3]

I am writing an Android app where I need the user to log in with Facebook.


Login works fine and I also get a profile picture, but the resolution of the picture is very low - about 50 px x 50 px. Is there a possibility to get a better one?


The following code is used to load the image, after the Facebook login process and a GraphRequest.newMeRequest.



public class LoadFacebookUserPicture extends AsyncTask<String, Void, Bitmap> {

private Context context;

public LoadFacebookUserPicture (Context context) {
this.context = context;
}

@Override
protected Bitmap doInBackground(String... params) {
try {
URL url = new URL(params[0]);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
FileOutputStream fos = context.openFileOutput("test.png", Context.MODE_PRIVATE);
myBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
return null;
} catch (Exception e) {
e.printStackTrace();
Log.e("LoadFacebookUserPicture", e.getMessage());
}
Log.e("LoadFacebookUserPicture", "Passt");
return null;
}

}

Aucun commentaire:

Enregistrer un commentaire