0

Converting bitmap to string and printing in toast message does not display string. I see the black screen

'MainActivity.java'

public void Upload(View v){

    StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
    StrictMode.setVmPolicy(builder.build());

    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (cameraIntent.resolveActivity(getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException ex) {
            // Error occurred while creating the File
            Log.i("HATA", "IOException");
        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
            cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
            startActivityForResult(cameraIntent, REQUEST_IMAGE_CAPTURE);
        }
    }

}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {

    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
        try {

            mImageBitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), Uri.parse(mCurrentPhotoPath));
            mImageView.setImageBitmap(mImageBitmap);

            Toast.makeText(getApplicationContext(),imageToString(mImageBitmap),Toast.LENGTH_LONG).show();


        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

I tried all options, Any help is appreciated.

Ravi
  • 881
  • 1
  • 9
  • 23
  • 2
    First of all you didn't describe your problem well, otherwise when you convert a bitmap to string, it's a too long string and maybe that's the problem why you can't see the Toast, you can Log the string if you need to see it. – Amine Mar 27 '19 at 16:21
  • I think Amine is right this is the reason for the black screen – Vipul Chauhan Mar 27 '19 at 17:40

0 Answers0