Skip to main content

Save Bitmap and sent it with Email attachment ANDROID

It is very simple to save BITMAP into image


 if (BITMAP != null) {  
                               try {  
                                    ByteArrayOutputStream bytes = new ByteArrayOutputStream();  
                                    BITMAP.compress(Bitmap.CompressFormat.PNG, 40,  
                                              bytes);  
                                    // you can create a new file name ".jpg" in  
                                    // sdcard folder.  
                                    String pngUri = Environment  
                                              .getExternalStorageDirectory()  
                                              + File.separator  
                                              + _KNAME  
                                              + "_"  
                                              + General_Class.selectitem_  
                                              + "_"  
                                              + _BVALUE  
                                              + "_View.jpg";  
                                    newFile = new File(pngUri);  
                                    newFile.createNewFile();  
                                    // write the bytes in file  
                                    FileOutputStream fo = new FileOutputStream(newFile);  
                                    fo.write(bytes.toByteArray());  
                                    // remember close de FileOutput  
                                    fo.close();  
                               } catch (Exception e) {  
                                    Log.d("error in save image", "-->"  
                                              + e.getMessage().toString());  
                               }  
                          }  

Use that image path in share intent.

 Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);  
                // set the type  
                shareIntent.setType("text/plain");  
                // add a subject  
                shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,  
                          "Email with attachmetn");  
                // build the body of the message to be shared  
                String shareMessage = "\n";  
                // add the message  
                shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,  
                          shareMessage);  
                shareIntent.putExtra(android.content.Intent.EXTRA_STREAM,  
                          Uri.fromFile(newFile));  
                // start the chooser for sharing  
                startActivity(Intent.createChooser(shareIntent,  
                          "Please select sharing medium"));  

enjoy coding...

Comments

Popular posts from this blog

Don't Ship AI Agent Skills Without Evals

At the AI Engineer World's Fair on July 1, 2026, Philipp Schmid, a Staff Engineer on the Gemini API and agents team at Google DeepMind, asked a room full of engineers a simple question: who uses skills with their coding agents? Every hand went up. Who has evals for those skills? Almost none. That gap is the entire talk, which Schmid also wrote up on his own blog, philschmid.de/testing-skills . His team indexed the skills ecosystem through SkillsBench and found the same pattern everywhere: people ship a SKILL.md file after two manual test runs and move on. It looks fine in a demo. It quietly corrupts outputs in production, because bad skills don't crash. They just make the agent confidently wrong. If you've already read our breakdown of Matt Pocock's Claude Code skills library , think of this as the other half of that story: what happens once you've installed a skill and it's actually running against real prompts. Key Takeaways SkillsBench indexed 47,000+ un...

Add flutter to existing app — Challenges

I am using flutter last 2 year & successfully released 2 flutter apps on production before 2–3 month, decide to add flutter in existing android & iOS app(while it was in beta-experimental stage). Flutter team have provide better way to add same in flutter v1.2 —  Good document than beta. Article is not about integrate flutter in existing app but, It’s about challenges which i have faced after adding flutter in existing app. I have integrate flutter module with my existing iOS & Android App (Same Application for both platform), developed 2 new features in flutter module & released successfully. In last week I have to add new feature in flutter module which user is able to pick file from phone & upload it on server. I have decided to use  file_picker: ^1.4.3+2 . Now, what I have is Native Application + Flutter Module < = > Image_picker Plugin in one App. In which I faced below challenges. Same time flutter v1.12 released A...

Android - Google MAP V2 PART 1

Download Full Code  of PART-1 , 2 , 3 , 4 Download and configure Google Play Services Library in Eclipse Google Map for Android is now integrated with Google Play Services. So we need to set up Google Play Service Library for developing Google Map application in Android. Get the API key for Google Maps v2: Linux  :  For any other OS use this :  keytool -list -v -alias androiddebugkey \ -keystore <path_to_debug_keystore>debug.keystore \ -storepass android -keypass android Register with the Google APIs Console :    Google APIs Console  Select here the  Services  entry: Activate the  Google Maps Android API v2 . Register your application via its package in this console together with the SHA-1 fingerprint of your signature key. Click on Create new Android Key.. Add you SHA-1 and your package name in to box like example given in alert box. Support library...