Camera Intent show blurred image preview after take a picture for some devices












1














I'm having some issues in taking picture using camera intent. It's alright in my and some of my friend's devices, but somehow it shows a little bug in samsung devices(mostly). When i take the picture, the preview of captured image seems so blurry. i've searched about it all over the internet and i found no answer.



The only thing i dont understand is that my code is doing well in my device test and btw i'm using google code so i'm pretty sure that will be okay in all devices. Now i'm so confused and dont know exactly what to do.



Here's my code :



My intent method :



private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
}
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(this,
"com.codelabs.refillmybottle.fileprovider",
photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, 1);
}
}
}


onActivityResult :



if (resultCode == RESULT_OK) {
if (requestCode == 1) {
File imgFile = new File(mCurrentPhotoPath);
Log.d(TAG, "imgfile size : " + imgFile.length());
if(imgFile.exists()){
Uri bp = Uri.fromFile(imgFile);
Bitmap mybitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
Bitmap bitmap = decodeUri(bp,300);
chipdata++;
encodedeImageData[chipdata - 1] = getEncoded64ImageStringFromBitmap(bitmap);
checkChipData();
checkData();
}
}


decodeUri is a method to decode you Uri to bitmap and resize it.



I do really hope that anyone could answer my error cause my boss got angry on me and i'm so confused :D. Thanks.










share|improve this question



























    1














    I'm having some issues in taking picture using camera intent. It's alright in my and some of my friend's devices, but somehow it shows a little bug in samsung devices(mostly). When i take the picture, the preview of captured image seems so blurry. i've searched about it all over the internet and i found no answer.



    The only thing i dont understand is that my code is doing well in my device test and btw i'm using google code so i'm pretty sure that will be okay in all devices. Now i'm so confused and dont know exactly what to do.



    Here's my code :



    My intent method :



    private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
    File photoFile = null;
    try {
    photoFile = createImageFile();
    } catch (IOException ex) {
    }
    if (photoFile != null) {
    Uri photoURI = FileProvider.getUriForFile(this,
    "com.codelabs.refillmybottle.fileprovider",
    photoFile);
    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
    startActivityForResult(takePictureIntent, 1);
    }
    }
    }


    onActivityResult :



    if (resultCode == RESULT_OK) {
    if (requestCode == 1) {
    File imgFile = new File(mCurrentPhotoPath);
    Log.d(TAG, "imgfile size : " + imgFile.length());
    if(imgFile.exists()){
    Uri bp = Uri.fromFile(imgFile);
    Bitmap mybitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
    Bitmap bitmap = decodeUri(bp,300);
    chipdata++;
    encodedeImageData[chipdata - 1] = getEncoded64ImageStringFromBitmap(bitmap);
    checkChipData();
    checkData();
    }
    }


    decodeUri is a method to decode you Uri to bitmap and resize it.



    I do really hope that anyone could answer my error cause my boss got angry on me and i'm so confused :D. Thanks.










    share|improve this question

























      1












      1








      1







      I'm having some issues in taking picture using camera intent. It's alright in my and some of my friend's devices, but somehow it shows a little bug in samsung devices(mostly). When i take the picture, the preview of captured image seems so blurry. i've searched about it all over the internet and i found no answer.



      The only thing i dont understand is that my code is doing well in my device test and btw i'm using google code so i'm pretty sure that will be okay in all devices. Now i'm so confused and dont know exactly what to do.



      Here's my code :



      My intent method :



      private void dispatchTakePictureIntent() {
      Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
      File photoFile = null;
      try {
      photoFile = createImageFile();
      } catch (IOException ex) {
      }
      if (photoFile != null) {
      Uri photoURI = FileProvider.getUriForFile(this,
      "com.codelabs.refillmybottle.fileprovider",
      photoFile);
      takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
      startActivityForResult(takePictureIntent, 1);
      }
      }
      }


      onActivityResult :



      if (resultCode == RESULT_OK) {
      if (requestCode == 1) {
      File imgFile = new File(mCurrentPhotoPath);
      Log.d(TAG, "imgfile size : " + imgFile.length());
      if(imgFile.exists()){
      Uri bp = Uri.fromFile(imgFile);
      Bitmap mybitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
      Bitmap bitmap = decodeUri(bp,300);
      chipdata++;
      encodedeImageData[chipdata - 1] = getEncoded64ImageStringFromBitmap(bitmap);
      checkChipData();
      checkData();
      }
      }


      decodeUri is a method to decode you Uri to bitmap and resize it.



      I do really hope that anyone could answer my error cause my boss got angry on me and i'm so confused :D. Thanks.










      share|improve this question













      I'm having some issues in taking picture using camera intent. It's alright in my and some of my friend's devices, but somehow it shows a little bug in samsung devices(mostly). When i take the picture, the preview of captured image seems so blurry. i've searched about it all over the internet and i found no answer.



      The only thing i dont understand is that my code is doing well in my device test and btw i'm using google code so i'm pretty sure that will be okay in all devices. Now i'm so confused and dont know exactly what to do.



      Here's my code :



      My intent method :



      private void dispatchTakePictureIntent() {
      Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
      File photoFile = null;
      try {
      photoFile = createImageFile();
      } catch (IOException ex) {
      }
      if (photoFile != null) {
      Uri photoURI = FileProvider.getUriForFile(this,
      "com.codelabs.refillmybottle.fileprovider",
      photoFile);
      takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
      startActivityForResult(takePictureIntent, 1);
      }
      }
      }


      onActivityResult :



      if (resultCode == RESULT_OK) {
      if (requestCode == 1) {
      File imgFile = new File(mCurrentPhotoPath);
      Log.d(TAG, "imgfile size : " + imgFile.length());
      if(imgFile.exists()){
      Uri bp = Uri.fromFile(imgFile);
      Bitmap mybitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
      Bitmap bitmap = decodeUri(bp,300);
      chipdata++;
      encodedeImageData[chipdata - 1] = getEncoded64ImageStringFromBitmap(bitmap);
      checkChipData();
      checkData();
      }
      }


      decodeUri is a method to decode you Uri to bitmap and resize it.



      I do really hope that anyone could answer my error cause my boss got angry on me and i'm so confused :D. Thanks.







      android android-intent camera blur






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 6:33









      IganovIganov

      86




      86
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Best Code in Camera take picture



          private int REQUEST_CAMERA = 0;
          String realPath;
          private void cameraIntent() {
          Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
          startActivityForResult(intent, REQUEST_CAMERA);
          }

          @Override
          public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);

          if (resultCode == Activity.RESULT_OK && data != null) {


          if (requestCode == REQUEST_CAMERA)
          onCaptureImageResult(data);


          }

          private void onCaptureImageResult(Intent data) {

          Bitmap photo = (Bitmap) data.getExtras().get("data");
          binding.profileImage.setImageBitmap(photo);


          // CALL THIS METHOD TO GET THE URI FROM THE BITMAP
          Uri tempUri = getImageUri(getApplicationContext(), photo);

          // CALL THIS METHOD TO GET THE ACTUAL PATH


          }

          private Uri getImageUri(Context inContext, Bitmap inImage) {
          ByteArrayOutputStream bytes = new ByteArrayOutputStream();
          inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
          realPath =MediaStore.Images.Media.insertImage(inContext.getContentResolver(),
          inImage, "Title", null);
          return Uri.parse(realPath);
          }





          share|improve this answer





















          • thanks for the answer though, isnt 'data.getExtras().get("data")' only give you a thumbnail?
            – Iganov
            Nov 13 '18 at 6:50










          • Bitmap inImage ; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
            – suresh madaparthi
            Nov 13 '18 at 6:54










          • use above code its work good
            – suresh madaparthi
            Nov 13 '18 at 6:54











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53275101%2fcamera-intent-show-blurred-image-preview-after-take-a-picture-for-some-devices%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Best Code in Camera take picture



          private int REQUEST_CAMERA = 0;
          String realPath;
          private void cameraIntent() {
          Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
          startActivityForResult(intent, REQUEST_CAMERA);
          }

          @Override
          public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);

          if (resultCode == Activity.RESULT_OK && data != null) {


          if (requestCode == REQUEST_CAMERA)
          onCaptureImageResult(data);


          }

          private void onCaptureImageResult(Intent data) {

          Bitmap photo = (Bitmap) data.getExtras().get("data");
          binding.profileImage.setImageBitmap(photo);


          // CALL THIS METHOD TO GET THE URI FROM THE BITMAP
          Uri tempUri = getImageUri(getApplicationContext(), photo);

          // CALL THIS METHOD TO GET THE ACTUAL PATH


          }

          private Uri getImageUri(Context inContext, Bitmap inImage) {
          ByteArrayOutputStream bytes = new ByteArrayOutputStream();
          inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
          realPath =MediaStore.Images.Media.insertImage(inContext.getContentResolver(),
          inImage, "Title", null);
          return Uri.parse(realPath);
          }





          share|improve this answer





















          • thanks for the answer though, isnt 'data.getExtras().get("data")' only give you a thumbnail?
            – Iganov
            Nov 13 '18 at 6:50










          • Bitmap inImage ; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
            – suresh madaparthi
            Nov 13 '18 at 6:54










          • use above code its work good
            – suresh madaparthi
            Nov 13 '18 at 6:54
















          0














          Best Code in Camera take picture



          private int REQUEST_CAMERA = 0;
          String realPath;
          private void cameraIntent() {
          Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
          startActivityForResult(intent, REQUEST_CAMERA);
          }

          @Override
          public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);

          if (resultCode == Activity.RESULT_OK && data != null) {


          if (requestCode == REQUEST_CAMERA)
          onCaptureImageResult(data);


          }

          private void onCaptureImageResult(Intent data) {

          Bitmap photo = (Bitmap) data.getExtras().get("data");
          binding.profileImage.setImageBitmap(photo);


          // CALL THIS METHOD TO GET THE URI FROM THE BITMAP
          Uri tempUri = getImageUri(getApplicationContext(), photo);

          // CALL THIS METHOD TO GET THE ACTUAL PATH


          }

          private Uri getImageUri(Context inContext, Bitmap inImage) {
          ByteArrayOutputStream bytes = new ByteArrayOutputStream();
          inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
          realPath =MediaStore.Images.Media.insertImage(inContext.getContentResolver(),
          inImage, "Title", null);
          return Uri.parse(realPath);
          }





          share|improve this answer





















          • thanks for the answer though, isnt 'data.getExtras().get("data")' only give you a thumbnail?
            – Iganov
            Nov 13 '18 at 6:50










          • Bitmap inImage ; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
            – suresh madaparthi
            Nov 13 '18 at 6:54










          • use above code its work good
            – suresh madaparthi
            Nov 13 '18 at 6:54














          0












          0








          0






          Best Code in Camera take picture



          private int REQUEST_CAMERA = 0;
          String realPath;
          private void cameraIntent() {
          Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
          startActivityForResult(intent, REQUEST_CAMERA);
          }

          @Override
          public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);

          if (resultCode == Activity.RESULT_OK && data != null) {


          if (requestCode == REQUEST_CAMERA)
          onCaptureImageResult(data);


          }

          private void onCaptureImageResult(Intent data) {

          Bitmap photo = (Bitmap) data.getExtras().get("data");
          binding.profileImage.setImageBitmap(photo);


          // CALL THIS METHOD TO GET THE URI FROM THE BITMAP
          Uri tempUri = getImageUri(getApplicationContext(), photo);

          // CALL THIS METHOD TO GET THE ACTUAL PATH


          }

          private Uri getImageUri(Context inContext, Bitmap inImage) {
          ByteArrayOutputStream bytes = new ByteArrayOutputStream();
          inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
          realPath =MediaStore.Images.Media.insertImage(inContext.getContentResolver(),
          inImage, "Title", null);
          return Uri.parse(realPath);
          }





          share|improve this answer












          Best Code in Camera take picture



          private int REQUEST_CAMERA = 0;
          String realPath;
          private void cameraIntent() {
          Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
          startActivityForResult(intent, REQUEST_CAMERA);
          }

          @Override
          public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);

          if (resultCode == Activity.RESULT_OK && data != null) {


          if (requestCode == REQUEST_CAMERA)
          onCaptureImageResult(data);


          }

          private void onCaptureImageResult(Intent data) {

          Bitmap photo = (Bitmap) data.getExtras().get("data");
          binding.profileImage.setImageBitmap(photo);


          // CALL THIS METHOD TO GET THE URI FROM THE BITMAP
          Uri tempUri = getImageUri(getApplicationContext(), photo);

          // CALL THIS METHOD TO GET THE ACTUAL PATH


          }

          private Uri getImageUri(Context inContext, Bitmap inImage) {
          ByteArrayOutputStream bytes = new ByteArrayOutputStream();
          inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
          realPath =MediaStore.Images.Media.insertImage(inContext.getContentResolver(),
          inImage, "Title", null);
          return Uri.parse(realPath);
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 6:43









          suresh madaparthisuresh madaparthi

          25419




          25419












          • thanks for the answer though, isnt 'data.getExtras().get("data")' only give you a thumbnail?
            – Iganov
            Nov 13 '18 at 6:50










          • Bitmap inImage ; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
            – suresh madaparthi
            Nov 13 '18 at 6:54










          • use above code its work good
            – suresh madaparthi
            Nov 13 '18 at 6:54


















          • thanks for the answer though, isnt 'data.getExtras().get("data")' only give you a thumbnail?
            – Iganov
            Nov 13 '18 at 6:50










          • Bitmap inImage ; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
            – suresh madaparthi
            Nov 13 '18 at 6:54










          • use above code its work good
            – suresh madaparthi
            Nov 13 '18 at 6:54
















          thanks for the answer though, isnt 'data.getExtras().get("data")' only give you a thumbnail?
          – Iganov
          Nov 13 '18 at 6:50




          thanks for the answer though, isnt 'data.getExtras().get("data")' only give you a thumbnail?
          – Iganov
          Nov 13 '18 at 6:50












          Bitmap inImage ; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
          – suresh madaparthi
          Nov 13 '18 at 6:54




          Bitmap inImage ; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
          – suresh madaparthi
          Nov 13 '18 at 6:54












          use above code its work good
          – suresh madaparthi
          Nov 13 '18 at 6:54




          use above code its work good
          – suresh madaparthi
          Nov 13 '18 at 6:54


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53275101%2fcamera-intent-show-blurred-image-preview-after-take-a-picture-for-some-devices%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()