Adonis Hart 5:25 AM Hello I have issue with ActivityResultContracts. I am trying to take photo and save it to the backend database. Thus I have to invoke the camera intent in my activity code, but during this process, I got stuck. The method startActivityForResult has already been deprecated, thus I have to use the registerActivityForResult(). So I tried the below code, but the ActivityResultContracts cannot not be found anywhere. I would be grateful if anyone has similar experience with this issue. š ActivityResultLauncher<Intent> cameraLauncher = registerForActivityResult( new ActivityResultContracts.StartActivityForResult(), result -> { if (result.getResultCode() == RESULT_OK) { Intent data = result.getData(); Bitmap photo = (Bitmap) data.getExtras().get("data");
// Save the photo to external storage
File photoFile = new File(Environment.getExternalStorageDirectory(), "photo.jpg");
try {
FileOutputStream fos = new FileOutputStream(photoFile);
photo.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
// Upload the photo file to the backend database using appropriate APIs or libraries
// Implement your backend integration logic here
}
});
FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.
Also, is this related to Appwrite at all?
Make sure to add the androidx.appcompat library to the project.
Recommended threads
- Flutter Android oAuth is no more working
I currently don't get the oAuth login to work in flutter android. it works on ios and on web. but when try to use it on Android, i get to the point where the ca...
- I'm experiencing a critical bug on Appwr...
Hey <@870607367597850624> team / support š I'm experiencing a critical bug on Appwrite Cloud that's blocking my production Flutter app. I've already filed GitH...
- Database listRows method call failing in...
I'm getting an error when trying to use listRows in a flutter app on a database. It seems something in the backend has changed because the production version of...