
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
- android kotlin error updatePhone
package vasu.apps.schooldashboard.Services import android.util.Log import io.appwrite.Client import io.appwrite.ID import io.appwrite.exceptions.AppwriteExcept...
- Google OAuth2 screen loop issue in Flut...
i am trying to authenticate user on my app using google, everything works fine, but even after succesfull authentication instead of redirecting back to the app,...
- getting network issue when trying to acc...
