title: How to place profile picture image on that place in Android?
body: <p>In my app, I want to put an image on the place where a user image is selected. In my fragment, I have one image view and one button, when I select an image from the gallery I cannot place the image on the Image View.</p>
  
  <p>Here is my code:</p>
  
  <p>Profile Fragment:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public class ProfileFragment extends Fragment {
      //private static Bitmap Image = null;
      private ImageView imageView;
      private static final int SELECT_PHOTO = 1;
  
      Button browseProfilePic;
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_layout_profilepic, container, false);
          imageView = (ImageView)view.findViewById(R.id.profile_image);
          browseProfilePic = (Button) view.findViewById(R.id.btn_pick);
          browseProfilePic.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {                   
                  Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
                  photoPickerIntent.setType("image/*");
                  startActivityForResult(photoPickerIntent, SELECT_PHOTO);
              }
          });
          return view;
      }
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
          super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
          switch(requestCode) {
              case SELECT_PHOTO:
                  if(resultCode == getActivity().RESULT_OK){
                      try {
                          final Uri imageUri = imageReturnedIntent.getData();
                          final InputStream imageStream = getActivity().getContentResolver().openInputStream(imageUri);
                          final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);
                          imageView.setImageBitmap(selectedImage);
                      } catch (FileNotFoundException e) {
                          e.printStackTrace();
                      }
                  }
          }
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>My activity:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>public class AccountActivity extends FragmentActivity {
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.account);
          String item = getIntent().getStringExtra("item");
          Fragment fragment = null;
          switch(item) {
              case "Balance": fragment = new BalanceFragment(); break;
              case "Personal": fragment = new PersonalFragment(); break;
              case "Work": fragment = new WorkFragment(); break;
              case "Address": fragment = new AddAddressFragment(); break;
              case "Vehicle": fragment = new AddVehicleFragment(); break;
              case "Preference": fragment = new PreferenceFragment(); break;
              case "About": fragment = new AboutFragment(); break;
              case "Settings": fragment = new SettingsFragment(); break;
              case "Help": fragment = new HelpFragment(); break;
              case "Profile":fragment = new ProfileFragment(); break;
              case "Logout":logout();break;
              default: fragment = new DefaultFragment(); break;
          }
  
          if (savedInstanceState == null) {
              FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
  //            AccountFragment fragment = new AccountFragment();
              transaction.replace(R.id.account_frame, fragment);
              transaction.commit();
          }
          setTitle(item);
      }
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode,resultCode,data);
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Please anyone help me.</p>