Capture Image in Android Activity with Result Contracts

capture-image-android

Google introduced Android ActivityResultContracts which can be used to pass data between activities. These contracts are a huge improvement over¬†onActivityResult() because they allow separating unrelated data transfers and can be easily reused across multiple activities. Basic Activity Result Contract ActivityResultLauncher launcher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { if(result.getResultCode() == RESULT_OK){ // handle activity result } … Read more