I don\'t know why, but I am always getting null when I try to get the profile picture of the user. Do I need to set some specific permissions to get access?
Below is
This should solve it. but be sure to access setfollowredirects statically i.e HttpURLConnection.setFollowRedirects(HttpURLConnection.getFollowRedirects());
url = new URL("https://graph.facebook.com/ID/picture?type=small");
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection.setFollowRedirects(HttpURLConnection.getFollowRedirects());
connection.setDoInput(true);
connection.connect();
input = connection.getInputStream();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeStream(input, null, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, 300, 300);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
options.inPreferredConfig = Config.RGB_565;
myBitmap= BitmapFactory.decodeStream(input, null, options);
or
url = new URL("https://graph.facebook.com/ID/picture?type=small");
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection.setFollowRedirects(HttpURLConnection.getFollowRedirects());
connection.setDoInput(true);
connection.connect();
input = connection.getInputStream();
myBitmap= BitmapFactory.decodeStream(input);
Hope this helps