I've really been stumped by this problem. My app uses Facebook SDK and has a fragment (PersonalFragment) attached to the Main Activity, part of which displays the current user's name in a Text View (R.id.textView), and the current user's image in an ImageView (R.id.imageView)
My problem is I use the following logic to get the profile picture URI, and then use verified code to get a Bitmap from a URI. The following code results in a simple: "e\FNF Exception: Profile Picture" being written into the Log.
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v=inflater.inflate(R.layout.fragment_personals, container, false);
ImageView image =(ImageView) (v.findViewById(R.id.imageView));
if(Profile.getCurrentProfile()!=null)
{
try {
Uri uri = (Profile.getCurrentProfile().getProfilePictureUri(100, 150));
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), uri);
image.setImageBitmap(bitmap);
image.setScaleType(ImageView.ScaleType.FIT_XY);
}
catch(FileNotFoundException f)
{
Log.e("FNF Exception","Profile Picture");
}
catch(IOException i)
{
Log.e("IO Exception", "Profile Picture");
}
}
((TextView)v.findViewById(R.id.textView)).setText(Profile.getCurrentProfile().getName());
As one can see, the try-catch is within the if statement, so Profile.getCurrentProfile() is certainly not null. Furthermore, the code correctly inputs the user's name into the textview. Only the profile picture code throws a FileNotFoundException.
Suggestions?