OnActivityResult sometimes not called after ACTION_GET_CONTENT intent

You must add following code for taking images from devices

choosebtn.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {
         Intent i1=new Intent();
         i1.setType("image/*");
         i1.setAction(Intent.ACTION_GET_CONTENT);
         startActivityForResult(i1,1);
      }
});


@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode == 1 && resultCode == RESULT_OK && data != null && data.getData() != null)
    {
        imguri=data.getData();
        mainpreview.setImageURI(data.getData());
    } else {
        Toast.makeText(getApplicationContext(),"please choose image",Toast.LENGTH_SHORT).show();
    }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)