Startup and Tech
Wednesday, 3 June 2020
Email Intent in Android Studio(Send email to your friend with your android application)
activity_main.xml
MainActivity.java
package com.example.emailintent; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.graphics.drawable.AnimationDrawable; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; public class MainActivity extends AppCompatActivity { LinearLayout ll; private EditText etto,etsubject,etmessage; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); etto = findViewById(R.id.et_to); etsubject = findViewById(R.id.et_subject); etmessage = findViewById(R.id.et_message); // below code is gradient effect part ll = findViewById(R.id.ll); AnimationDrawable animationDrawable = (AnimationDrawable) ll.getBackground(); animationDrawable.setEnterFadeDuration(2000); animationDrawable.setExitFadeDuration(4000); animationDrawable.start(); } public void Sendemail(View view) //implict intent code - for sending email { String to = etto.getText().toString(); String tolist[] = to.split("\n"); String subject = etsubject.getText().toString(); String message = etmessage.getText().toString(); Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_EMAIL,tolist); intent.putExtra(Intent.EXTRA_SUBJECT,subject); intent.putExtra(Intent.EXTRA_TEXT,message); intent.setType("message/rfc822"); Intent chooser = intent.createChooser(intent,"choose for sending email"); startActivity(chooser); } }
Output
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment