I have a application where i convert the text coming from user into a QR code and display the QR code in imageView. My problem is how can i use sharing Intent on this image as their no path specified for it nor the image is stored anywhere ?
            Asked
            
        
        
            Active
            
        
            Viewed 276 times
        
    0
            
            
        - 
                    u need to save the bitmap then share using filepath – Adeel Turk May 09 '17 at 07:31
 - 
                    1http://stackoverflow.com/a/32829056/4265664 – Anudeep May 09 '17 at 07:34
 - 
                    Cant you save the image as temp somewhere and delete it when you dont need it anymore? – Tirolel May 09 '17 at 08:08
 
1 Answers
0
            You can do it by saving the bitmap of image in cache followed by sharing it.
//To get the bitmap from Imageview
imageView.setDrawingCacheEnabled(true);
Bitmap bitmap = imageView.getDrawingCache();
//To share it via Intent**
try {
    File file = new File(getContext().getCacheDir(), fileName + ".png");
    FileOutputStream fOut = new FileOutputStream(file);
    bitmap.compress(CompressFormat.PNG, 100, fOut);
    fOut.flush();
    fOut.close();
    file.setReadable(true, false);
    final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
    intent.setType("image/png");
    startActivity(intent);
} catch (Exception e) {
    e.printStackTrace();
}
        Chetan Talwar
        
- 111
 - 1
 - 6