1pickimage.setOnClickListener(new View.OnClickListener() {
2 @Override
3 public void onClick(View v) {
4 if(checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)
5 {
6 ChoosePicture();
7 }else{
8 String[] myPermission={Manifest.permission.READ_EXTERNAL_STORAGE};
9 requestPermissions(myPermission,750);
10 }
11
12 }
13});
14
15//if(checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) is asking if permission to read External Storage is granted
16//if yes execute method ChoosePicture(); and choose a pictrue from your device
17//if not ask for permission by copy_paste the code in the else brackets
18//in requestPermissions(myPermission,750); you can send any number other than 750 it doesnt matter
19