문제

When i press share button I want to take screen shot for my application (Activity which have the button) and share it by share intent

I try this code for taking the screen shot

 View v1 = L1.getRootView();
            v1.setDrawingCacheEnabled(true);
            Bitmap bm = v1.getDrawingCache();

It take a screen shot successfully But i don't know how to share it

If any one can tell me how to share this screen shot or give me another code

도움이 되었습니까?

해결책

To share the image, see the below function.

private void shareImage() {
Intent share = new Intent(Intent.ACTION_SEND);
 
    // If you want to share a png image only, you can do:

        // setType("image/png"); OR for jpeg: setType("image/jpeg");
        share.setType("image/*");
     
        // Make sure you put example png image named myImage.png in your
        // directory
        String imagePath = Environment.getExternalStorageDirectory()
                + "/myImage.png";
     
        File imageFileToShare = new File(imagePath);
     
        Uri uri = Uri.fromFile(imageFileToShare);
        share.putExtra(Intent.EXTRA_STREAM, uri);
     
        startActivity(Intent.createChooser(share, "Share Image!"));
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top