android - How to attach an image from an app to gmail -
Text after "div class =" itemprop = "text">
The application to take a picture and attach it to the screen and attach to the second screen, 1 button on the 2nd Gmail Photo on; Send it to someone I am using this code for the second button
View public void onClick (v) {// TODO Auto-generated method stub Intent intent = new Intent (Intent. ACTION_SENDTO, Uri.fromParts ("mailto", "test@gmail.com", tap)); Intent.putExtra (Intent.EXTRA_SUBJECT, "test"); Intent.putExtra (Intent.EXTRA_TEXT, "text"); Intent.putExtra (Intent.EXTRA_STREAM, imageUri); StartActivity (Intent.createChooser (meaning, "Choose an Email Client:")); } But this does not attach the photo to Gmail. It may be wrong here is the rest of the code.
The public class increases the main activity activity {Private Static Ent TAKE_PICTURE = 1; Private Uri image Yuri; @ Override protected void saved create (bundled Instansstet) {Suprknkret (saved Instensstet); SetContentView (R.layout.activity_main); Button sendbutton = (button) findViewById (R.id.sendbutton); sendbutton.setOnClickListener (New View.OnClickListener () {@Override public void onClick (View v) {// TODO Auto-generated method stub Intent intent = new Intent (Intent.ACTION_SENDTO, Uri.fromParts ( "mailto", "test @ gmail.com ", nULL)); intent.putExtra (Intent.EXTRA_SUBJECT," test "); intent.putExtra (Intent.EXTRA_TEXT," text "); intent.putExtra (Intent.EXTRA_STREAM, imageUri); startActivity (intent CreateChooser (intent, "Choose an Email Client:"));}}); Button camera button = (button) Find VVBIID (R.D.Button_Camera); CameraButton.setOnClickListener (cameraListener); } Private OnClickListener Camera Listener = New OnListList () {Click on Public Zero (see V) {Lephoto (V); }}; Public Zero Lefoto (see V) {intent = new intent ("android.media.action.IMAGE_CAPTURE"); File photo = new file (environment .getExternalStoragePublicDirectory (environment. DIRECTORY_PICTURES), "pic.jpg"); Intent.putExtra (MediaStore.EXTRA_OUTPUT, Uri.fromFile (photo)); ImageUri = Uri.framefile (photo); StartActivityForResult (intent, TAKE_PICTURE); } @ Override Public Boolean on Krait Option Menu (menu menu) {getMenuInflater (). Flood (R. menu menu, menu); Back true; } @Override Public Zero onActivityResult (integer requestCode, integer resultCode, intent data) {super.onActivityResult (requestCode, resultCode, data); Switch (requestcode) {case 1: if (resultCode == activity. RESULT_OK) {Ure selected image = image URI; GetContentResolver () Inform (selected image, blank); ImageView imageView = (ImageView) findViewById (R.id.image_view_camera); ContentResolver cr = getContentResolver (); Bitmap bitmap; {Try bitmap = android.provider.MediaStore.Images.Media .getBitmap (cr, selected image); ImageView.setImageBitmap (bitmap); Toast.makeText (MainActivity.this, selectedImage.toString (), Toast.LENGTH_LONG) .show (); } Hold (exception e) {toast. Make Text (main activity. "This failed to load", Toast. LNNHHLANG). Show (); }}}}}}
Try it
You see can more on this link:
View public void onClick (v) {// TODO auto-generated method stub effect sharingIntent = new intent (Intent.ACTION_SEND); SharingIntent.setType ("image / png"); SharingIntent.putExtra (Intent.EXTRA_SUBJECT, "test"); SharingIntent.putExtra (Intent.EXTRA_TEXT, "text"); Sharer Input Extra (Intent.EXTRA_STREAM, targetUri); StartActivity (Intent.createChooser (Share, "Share Image Using")); }
Comments
Post a Comment