image from camera intent issue in android

后端 未结 1 1006
故里飘歌
故里飘歌 2020-12-20 02:15

I am integrating facebook with android and I want when taking a phot , save it to sdcard and then upload it to facebook.

Here is my code:

photo_up=(B         


        
相关标签:
1条回答
  • 2020-12-20 02:55

    While using the generic code available on net to call camera and take photo and retrive it, I faced some problem in SAMSUNG device at that time the same error occured Failure delivering result ResultInfo and couldn't find any solution may be its because of any API Level or Device dependancy.

    But to overcome it I wrote my code another way to do the task, The code is here:

    1) To Call Camera

            String _path = Environment.getExternalStorageDirectory()
            + File.separator + "TakenFromCamera.png";
            File file = new File(_path);
            Uri outputFileUri = Uri.fromFile(file);
            Intent intent = new Intent(
            android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            startActivityForResult(intent, 1212);
    

    2) In ActivityResult to get Bitmap

                if (requestCode == 1212) {
                    String _path = Environment.getExternalStorageDirectory()
                    + File.separator + "TakenFromCamera.png";
                    mBitmap = BitmapFactory.decodeFile(_path);
                    if (mBitmap == null) {
                        // bitmap still null
                    } else {
                        // set bitmap in imageview
                    }
                }
    
    0 讨论(0)
提交回复
热议问题