Android 摄像头捕获的图像共享到不同的应用程序

Android 摄像头捕获的图像共享到不同的应用程序,android,android-camera,share,Android,Android Camera,Share,我正在开发一个应用程序,其中有一部分是拍摄图像 从相机和共享图像到不同的应用程序。我正在使用一个代码,但它没有共享图像。请看一看,告诉我哪里错了 Uri.parsefile://+sharefile请改用Uri.parsefile://+sharefile.getAbsolutePath。告诉我到底发生了什么,因为你没有那样做。用户看到了什么?@greenapps:-没有发生任何事情,它没有共享图像。。。此外,我在logcat中也没有收到任何错误..:什么都没发生?准确地告诉用户做了什么,看到了

我正在开发一个应用程序,其中有一部分是拍摄图像 从相机和共享图像到不同的应用程序。我正在使用一个代码,但它没有共享图像。请看一看,告诉我哪里错了


Uri.parsefile://+sharefile请改用Uri.parsefile://+sharefile.getAbsolutePath。告诉我到底发生了什么,因为你没有那样做。用户看到了什么?@greenapps:-没有发生任何事情,它没有共享图像。。。此外,我在logcat中也没有收到任何错误..:什么都没发生?准确地告诉用户做了什么,看到了什么。如果图像是在该文件夹中创建的,您是否与ES FileExplorer之类的文件资源管理器进行了检查?您的代码流有多远?告诉我getAbsilutePath的值到底是多少。告诉你的代码的哪一部分被执行了,哪一部分没有被执行。@greenapps在捕获图像后,我按下了共享按钮。它提供了应用程序选项,因此我可以选择像watsapp、facebook、mail等任何人来共享该图像。。当我选择任何选项时,它会打开相应的应用程序,并询问我您想要与XYZ共享。当我按“是”时,它会将控件返回到相机布局,而不共享图像。确定。那更好。但我要求更多的信息。请提供那个信息。
image = (ImageView)findViewById(R.id.image);

        share = (Button)findViewById(R.id.share);

        click = (Button)findViewById(R.id.click);

        click.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(intent, CAMERA_PIC_REQUEST);

            }
        });

        share.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

BitmapDrawable bitmapDrawable = (BitmapDrawable)image.getDrawable();

                Bitmap bitmap = bitmapDrawable.getBitmap();

                // Save this bitmap to a file.
                File cache = getApplicationContext().getExternalCacheDir();
                File sharefile = new File(cache, "toshare.png");
                try {
                FileOutputStream out = new FileOutputStream(sharefile);
                bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
                out.flush();
                out.close();
                } catch (IOException e) {
                }

                // Now send it out to share
                Intent share = new Intent(android.content.Intent.ACTION_SEND);
                share.setType("image/*");
                share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + sharefile));
                try {
                startActivity(Intent.createChooser(share, "Share photo"));
                } catch (Exception e) {
                }

            }
        });
    }
         protected void onActivityResult(int requestCode, int resultCode, Intent data) {

                if (requestCode == CAMERA_PIC_REQUEST) {
                    //2
                    Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); 
                    image.setImageBitmap(thumbnail);
                    //3
                    share.setVisibility(0);
                    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                    thumbnail.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
                    //4
                    File file = new File(Environment.getExternalStorageDirectory()+File.separator + "image.jpg");
                    try {
                        file.createNewFile();
                        FileOutputStream fo = new FileOutputStream(file);
                        //5
                        fo.write(bytes.toByteArray());
                        fo.close();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

           }
         }

  }