Open sceddd opened 1 year ago
Im try to get image from lib or camera but it's return error "Image provider can not be null". Any idea...
public class MainActivity extends AppCompatActivity { private ImageButton temp; private Uri image_uri; ImageButton inputImg; ImageView outputImg; Button submit; private ProgressBar prg; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); prg = findViewById(R.id.progressbar); inputImg = findViewById(R.id.dadImg); outputImg = findViewById(R.id.momImg); submit = findViewById(R.id.submit); inputImg.setOnClickListener(this::onImageClick); submit.setOnClickListener(this::postData); } public void postData(View v) { ... } public void onImageClick(View v) { Intent imagePicker = ImagePicker.Companion.with(MainActivity.this) .maxResultSize(1080, 1080, true).provider(ImageProvider.BOTH).createIntent(); launcher.launch(imagePicker); } ActivityResultLauncher<Intent> launcher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), (ActivityResult result) -> { if (result.getResultCode() == RESULT_OK) { Uri uri = result.getData().getData(); inputImg.setImageURI(uri); // Use the uri to load the image } else if (result.getResultCode() == ImagePicker.RESULT_ERROR) { ImagePicker.Companion.getError(result.getData()); } }); }
Im try to get image from lib or camera but it's return error "Image provider can not be null". Any idea...