1
Guys I’m trying to get the fb profile image but returns the following error
java.io.Filenotfoundexception: No content Provider: https://graph.facebook.com/--Aqui--esta--o--id--/picture?width=150&height=150
My code is like this
Bitmap tempBitmap;
tempBitmap = Util.getBitmapFromURL(Preference.getUserPhoto(getApplicationContext()));
Drawable drawable = new BitmapDrawable(getResources(), tempBitmap);
System.out.println("TempBitMap "+ tempBitmap );
System.out.println("drawable "+ drawable );
aux.setIcon(drawable);
Class preference metodo getUserPhoto
public static String getUserPhoto(Context c){
SharedPreferences prefs = c.getSharedPreferences("myPref", 0);
return prefs.getString("url", "url");
}
My url eh this
url: https://graph.facebook.com/IDESTAACQUI/picture?width=150&height=150
Medoto to get the photo
public static Bitmap getBitmapFromURL(String src) {
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
} catch (Exception e) {
// Log exception
return null;
}
}
Bitmap and drawable result
Tempbitmap null drawable android.graphics.drawable.Bitmapdrawable@22b0eb58
Is the profile photo you are trying to get private? (Photo privacy is only me or only friends who can view)?
– Laerte
Not this as private, the strange thing is that when I play the link in the browser appears the photo but in my code when I try to convert to bitmap it gives that error
– roque