Category : onactivityresult

My app has 3 activities; MainActivity has a large ImgeView with a jpg picture in main layout. Activities are changed with this code: Intent i = new Intent(this, Activity1.class); startActivityForResult(i,70);// arbitrary and back to MainActivity with code: protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case 70: // ..

Read more

I am using ActivityResultContract API in my fragment. Fragment A is in Activity A, from where Activity B is called which has Fragment B. Code in Fragment A is as follows: val makePaymentContract = registerForActivityResult(CustomContract()) { uri: Uri? -> Log.d("FragmentA", "DATA URI: ${uri.toString()}") } This is custom contract: class CustomContract : ActivityResultContract<DataHolder, Uri>() { override ..

Read more

@Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_WRITE_EXTERNAL && resultCode == RESULT_OK) { if (data.getClipData() != null) { int count = data.getClipData().getItemCount(); for (int i = 0; i < count; i++) { Uri uri = data.getClipData().getItemAt(i).getUri(); fileArrayList.add(uri); } //replaceFragment(fileArrayList); } else { if (data.getData()!=null){ Uri ..

Read more

I am using Intents to open the camera and take images from it. but the image gets pixelated. Is there any proper way of taking high-resolution images and saving them to the gallery? Here is my Intent code if (options[item].equals("Take Photo")) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, 1); } else if (options[item].equals("Choose ..

Read more

I am creating an application and am currently wondering how do I save an image to SharedPreferences, and then retrieve that same image, please see below the code I have regarding the Images. What do I need to add to this? public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data){ super.onActivityResult(requestCode, resultCode, data); // Checks ..

Read more

I use the following codes for capturing video. Everything is ok but after capturing video, the registerForActivityResult(ActivityResultContracts.TakeVideo()) is always null. The captured video exists in the given path. In what ways I can resolve this issue? private fun openCameraForMovie() { val packageManager = requireContext().packageManager Intent(MediaStore.ACTION_VIDEO_CAPTURE).also { takeVideoIntent -> takeVideoIntent.resolveActivity(packageManager)?.also { startRecording() } } } private ..

Read more

Clicking on profile image in a fragment, goes to profile Activity. Now on backPress finishing the acitivity and goes back to fragment. Now in fragment how can i get value from setResult which i am passing while closing activity as shown in the below code: Activity Code: private void closeActivity(boolean isFollowClicked) { Intent resultIntent = ..

Read more