Image from gallery or camera in Android .
Add dependency in gradle.
implementation 'com.github.Mariovc:ImagePicker:1.0.5'
On Button Click Call.
fp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { search_earn_money8.setVisibility(View.VISIBLE); ImagePicker.setMinQuality(600, 800); ImagePicker.pickImage(Report.this, "Select your image:"); } });@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK && data.getData() != null) { bitmaps = ImagePicker.getImageFromResult(this, requestCode, resultCode, data); Uri uri = data.getData(); getRealPathFromURI(uri); search_earn_money8.setImageBitmap(bitmaps);// set image on imageview. } // TODO do something with the bitmap} private String getRealPathFromURI(Uri contentURI) { thePath = "no-path-found"; String[] filePathColumn = {MediaStore.Images.Media.DISPLAY_NAME}; Cursor cursor = getContentResolver().query(contentURI, filePathColumn, null, null, null); if(cursor.moveToFirst()){ int columnIndex = cursor.getColumnIndex(filePathColumn[0]); thePath = cursor.getString(columnIndex); } cursor.close(); return thePath; }