Saturday, September 3, 2011

[android-developers] Share View as Image

Hi

I am trying to share a view from my app as a jpeg (almost like a screen shot).
My code is below. Can any one tell me what is wrong? It doesnt cause an error but the image being shared is not there.

Any Help would be great. Thanks in advance.


         String cachePath = this.getCacheDir().getPath() ;
       
        Bitmap viewCapture = null;
        graphView.setDrawingCacheEnabled(true);
       
        viewCapture = Bitmap.createBitmap(graphView.getDrawingCache());
       
        graphView.setDrawingCacheEnabled(false);
       
        viewCapture.compress(CompressFormat.JPEG, 100, new FileOutputStream(cachePath+"/Image.jpeg"));
       
        Intent share = new Intent(Intent.ACTION_SEND);
        share.setType("image/jpeg");
       
        File file = new File(cachePath+"/Image.jpeg");
        Log.i(TAG,"Info: "+file.exists()+" - "+file.canRead()+" - "+file.getName()); // this returns true - true - Image.jpeg
        Uri outputFileUri = Uri.fromFile(file);
        share.putExtra(Intent.EXTRA_STREAM,outputFileUri);
        startActivity(Intent.createChooser(share, "Share Image"));

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment