Android - Sending Email

<blockquote > <p ><b >Email</b>is messages distributed by electronic means from one system user to one or more recipients via a network</p> </blockquote> <p >Before starting Email Activity, You must know Email functionality with intent, Intent is carrying data from one component to another component with-in the application or outside the application</p> <p >To send an email from your application, you don&rsquo;t have to implement an email client from the beginning, but you can use an existing one like the default Email app provided from Android, Gmail, Outlook, K-9 Mail etc. For this purpose, we need to write an Activity that launches an email client, using an implicit Intent with the right action and data. In this example, we are going to send an email from our app by using an Intent object that launches existing email clients.</p> <p >Following section explains different parts of our Intent object required to send an email.</p> <h2 >Intent Object - Action to send Email</h2> <p >You will use<b >ACTION_SEND</b>action to launch an email client installed on your Android device. Following is simple syntax to create an intent with ACTION_SEND action</p> <pre class="prettyprint notranslate prettyprinted" > <span class="typ" >Intent</span><span class="pln" > emailIntent </span><span class="pun" >=</span><span class="pln" > </span><span class="kwd" >new</span><span class="pln" > </span><span class="typ" >Intent</span><span class="pun" >(</span><span class="typ" >Intent</span><span class="pun" >.</span><span class="pln" >ACTION_SEND</span><span class="pun" >);</span></pre> <h2 >Intent Object - Data/Type to send Email</h2> <p >To send an email you need to specify<b >mailto:</b>as URI using setData() method and data type will be to<b >text/plain</b>using setType() method as follows &minus;</p> <pre class="prettyprint notranslate prettyprinted" > <span class="pln" >emailIntent</span><span class="pun" >.</span><span class="pln" >setData</span><span class="pun" >(</span><span class="typ" >Uri</span><span class="pun" >.</span><span class="pln" >parse</span><span class="pun" >(</span><span class="str" >&quot;mailto:&quot;</span><span class="pun" >));</span><span class="pln" > emailIntent</span><span class="pun" >.</span><span class="pln" >setType</span><span class="pun" >(</span><span class="str" >&quot;text/plain&quot;</span><span class="pun" >);</span></pre> <h2 >Intent Object - Extra to send Email</h2> <p >Android has built-in support to add TO, SUBJECT, CC, TEXT etc. fields which can be attached to the intent before sending the intent to a target email client. You can use following extra fields in your email &minus;</p> <table class="table table-bordered" > <tbody > <tr > <th >Sr.No.</th> <th >Extra Data &amp; Description</th> </tr> <tr > <td >1</td> <td ><b >EXTRA_BCC</b> <p >A String[] holding e-mail addresses that should be blind carbon copied.</p> </td> </tr> <tr > <td >2</td> <td ><b >EXTRA_CC</b> <p >A String[] holding e-mail addresses that should be carbon copied.</p> </td> </tr> <tr > <td >3</td> <td ><b >EXTRA_EMAIL</b> <p >A String[] holding e-mail addresses that should be delivered to.</p> </td> </tr> <tr > <td >4</td> <td ><b >EXTRA_HTML_TEXT</b> <p >A constant String that is associated with the Intent, used with ACTION_SEND to supply an alternative to EXTRA_TEXT as HTML formatted text.</p> </td> </tr> <tr > <td >5</td> <td ><b >EXTRA_SUBJECT</b> <p >A constant string holding the desired subject line of a message.</p> </td> </tr> <tr > <td >6</td> <td ><b >EXTRA_TEXT</b> <p >A constant CharSequence that is associated with the Intent, used with ACTION_SEND to supply the literal data to be sent.</p> </td> </tr> <tr > <td >7</td> <td ><b >EXTRA_TITLE</b> <p >A CharSequence dialog title to provide to the user when used with a ACTION_CHOOSER.</p> </td> </tr> </tbody> </table> <p >Here is an example showing you how to assign extra data to your intent &minus;</p> <pre class="prettyprint notranslate prettyprinted" > <span class="pln" >emailIntent</span><span class="pun" >.</span><span class="pln" >putExtra</span><span class="pun" >(</span><span class="typ" >Intent</span><span class="pun" >.</span><span class="pln" >EXTRA_EMAIL </span><span class="pun" >,</span><span class="pln" > </span><span class="kwd" >new</span><span class="pln" > </span><span class="typ" >String</span><span class="pun" >[]{</span><span class="str" >&quot;Recipient&quot;</span><span class="pun" >});</span><span class="pln" > emailIntent</span><span class="pun" >.</span><span class="pln" >putExtra</span><span class="pun" >(</span><span class="typ" >Intent</span><span class="pun" >.</span><span class="pln" >EXTRA_SUBJECT</span><span class="pun" >,</span><span class="pln" > </span><span class="str" >&quot;subject&quot;</span><span class="pun" >);</span><span class="pln" > emailIntent</span><span class="pun" >.</span><span class="pln" >putExtra</span><span class="pun" >(</span><span class="typ" >Intent</span><span class="pun" >.</span><span class="pln" >EXTRA_TEXT </span><span class="pun" >,</span><span class="pln" > </span><span class="str" >&quot;Message Body&quot;</span><span class="pun" >);</span></pre> <p >The out-put of above code is as below shown an image</p> <p><img alt="Email" src="http://www.tutorialspoint.com/android/images/email.jpg" /></p> <h4 align="center" >EMAIL EXAMPLE</h4> <h2 >Example</h2> <p >Following example shows you in practical how to use Intent object to launch Email client to send an Email to the given recipients.</p> <blockquote >To Email experiment with this example, you will need actual Mobile device equipped with latest Android OS(Android lollipop), otherwise you might get struggle with emulator which may not work properly. Second you will need to have an Email client like GMail(By default every android version having Gmail client App) or K9mail installed on your device.</blockquote> <table class="table table-bordered" > <tbody > <tr > <th class="fivepct" >Step</th> <th >Description</th> </tr> <tr > <td >1</td> <td >You will use Android studio to create an Android application and name it as<i >Tutorialspoint</i>under a package<i >com.example.tutorialspoint</i>. While creating this project, make sure you<i >Target SDK</i>and<i >Compile With</i>at the latest version of Android SDK to use higher levels of APIs.</td> </tr> <tr > <td >2</td> <td >Modify<i >src/MainActivity.java</i>file and add required code to take care of sending email.</td> </tr> <tr > <td >3</td> <td >Modify layout XML file<i >res/layout/activity_main.xml</i>add any GUI component if required. I&#39;m adding a simple button to launch Email Client.</td> </tr> <tr > <td >4</td> <td >Modify<i >res/values/strings.xml</i>to define required constant values</td> </tr> <tr > <td >5</td> <td >Modify<i >AndroidManifest.xml</i>as shown below</td> </tr> <tr > <td >6</td> <td >Run the application to launch Android emulator and verify the result of the changes done in the application.</td> </tr> </tbody> </table> <p >Following is the content of the modified main activity file<b >src/com.example.Tutorialspoint/MainActivity.java</b>.</p> <pre class="prettyprint notranslate prettyprinted" > <span class="kwd" >package</span><span class="pln" > com</span><span class="pun" >.</span><span class="pln" >example</span><span class="pun" >.</span><span class="pln" >tutorialspoint</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >net</span><span class="pun" >.</span><span class="typ" >Uri</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >os</span><span class="pun" >.</span><span class="typ" >Bundle</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >app</span><span class="pun" >.</span><span class="typ" >Activity</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >content</span><span class="pun" >.</span><span class="typ" >Intent</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >util</span><span class="pun" >.</span><span class="typ" >Log</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >view</span><span class="pun" >.</span><span class="typ" >Menu</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >view</span><span class="pun" >.</span><span class="typ" >View</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >widget</span><span class="pun" >.</span><span class="typ" >Button</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >import</span><span class="pln" > android</span><span class="pun" >.</span><span class="pln" >widget</span><span class="pun" >.</span><span class="typ" >Toast</span><span class="pun" >;</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >class</span><span class="pln" > </span><span class="typ" >MainActivity</span><span class="pln" > </span><span class="kwd" >extends</span><span class="pln" > </span><span class="typ" >Activity</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="lit" >@Override</span><span class="pln" > </span><span class="kwd" >protected</span><span class="pln" > </span><span class="kwd" >void</span><span class="pln" > onCreate</span><span class="pun" >(</span><span class="typ" >Bundle</span><span class="pln" > savedInstanceState</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="kwd" >super</span><span class="pun" >.</span><span class="pln" >onCreate</span><span class="pun" >(</span><span class="pln" >savedInstanceState</span><span class="pun" >);</span><span class="pln" > setContentView</span><span class="pun" >(</span><span class="pln" >R</span><span class="pun" >.</span><span class="pln" >layout</span><span class="pun" >.</span><span class="pln" >activity_main</span><span class="pun" >);</span><span class="pln" > </span><span class="typ" >Button</span><span class="pln" > startBtn </span><span class="pun" >=</span><span class="pln" > </span><span class="pun" >(</span><span class="typ" >Button</span><span class="pun" >)</span><span class="pln" > findViewById</span><span class="pun" >(</span><span class="pln" >R</span><span class="pun" >.</span><span class="pln" >id</span><span class="pun" >.</span><span class="pln" >sendEmail</span><span class="pun" >);</span><span class="pln" > startBtn</span><span class="pun" >.</span><span class="pln" >setOnClickListener</span><span class="pun" >(</span><span class="kwd" >new</span><span class="pln" > </span><span class="typ" >View</span><span class="pun" >.</span><span class="typ" >OnClickListener</span><span class="pun" >()</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >void</span><span class="pln" > onClick</span><span class="pun" >(</span><span class="typ" >View</span><span class="pln" > view</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > sendEmail</span><span class="pun" >();</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="pun" >});</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="kwd" >protected</span><span class="pln" > </span><span class="kwd" >void</span><span class="pln" > sendEmail</span><span class="pun" >()</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="typ" >Log</span><span class="pun" >.</span><span class="pln" >i</span><span class="pun" >(</span><span class="str" >&quot;Send email&quot;</span><span class="pun" >,</span><span class="pln" > </span><span class="str" >&quot;&quot;</span><span class="pun" >);</span><span class="pln" > </span><span class="typ" >String</span><span class="pun" >[]</span><span class="pln" > TO </span><span class="pun" >=</span><span class="pln" > </span><span class="pun" >{</span><span class="str" >&quot;&quot;</span><span class="pun" >};</span><span class="pln" > </span><span class="typ" >String</span><span class="pun" >[]</span><span class="pln" > CC </span><span class="pun" >=</span><span class="pln" > </span><span class="pun" >{</span><span class="str" >&quot;&quot;</span><span class="pun" >};</span><span class="pln" > </span><span class="typ" >Intent</span><span class="pln" > emailIntent </span><span class="pun" >=</span><span class="pln" > </span><span class="kwd" >new</span><span class="pln" > </span><span class="typ" >Intent</span><span class="pun" >(</span><span class="typ" >Intent</span><span class="pun" >.</span><span class="pln" >ACTION_SEND</span><span class="pun" >);</span><span class="pln" > emailIntent</span><span class="pun" >.</span><span class="pln" >setData</span><span class="pun" >(</span><span class="typ" >Uri</span><span class="pun" >.</span><span class="pln" >parse</span><span class="pun" >(</span><span class="str" >&quot;mailto:&quot;</span><span class="pun" >));</span><span class="pln" > emailIntent</span><span class="pun" >.</span><span class="pln" >setType</span><span class="pun" >(</span><span class="str" >&quot;text/plain&quot;</span><span class="pun" >);</span><span class="pln" > emailIntent</span><span class="pun" >.</span><span class="pln" >putExtra</span><span class="pun" >(</span><span class="typ" >Intent</span><span class="pun" >.</span><span class="pln" >EXTRA_EMAIL</span><span class="pun" >,</span><span class="pln" > TO</span><span class="pun" >);</span><span class="pln" > emailIntent</span><span class="pun" >.</span><span class="pln" >putExtra</span><span class="pun" >(</span><span class="typ" >Intent</span><span class="pun" >.</span><span class="pln" >EXTRA_CC</span><span class="pun" >,</span><span class="pln" > CC</span><span class="pun" >);</span><span class="pln" > emailIntent</span><span class="pun" >.</span><span class="pln" >putExtra</span><span class="pun" >(</span><span class="typ" >Intent</span><span class="pun" >.</span><span class="pln" >EXTRA_SUBJECT</span><span class="pun" >,</span><span class="pln" > </span><span class="str" >&quot;Your subject&quot;</span><span class="pun" >);</span><span class="pln" > emailIntent</span><span class="pun" >.</span><span class="pln" >putExtra</span><span class="pun" >(</span><span class="typ" >Intent</span><span class="pun" >.</span><span class="pln" >EXTRA_TEXT</span><span class="pun" >,</span><span class="pln" > </span><span class="str" >&quot;Email message goes here&quot;</span><span class="pun" >);</span><span class="pln" > </span><span class="kwd" >try</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > startActivity</span><span class="pun" >(</span><span class="typ" >Intent</span><span class="pun" >.</span><span class="pln" >createChooser</span><span class="pun" >(</span><span class="pln" >emailIntent</span><span class="pun" >,</span><span class="pln" > </span><span class="str" >&quot;Send mail...&quot;</span><span class="pun" >));</span><span class="pln" > finish</span><span class="pun" >();</span><span class="pln" > </span><span class="typ" >Log</span><span class="pun" >.</span><span class="pln" >i</span><span class="pun" >(</span><span class="str" >&quot;Finished sending email...&quot;</span><span class="pun" >,</span><span class="pln" > </span><span class="str" >&quot;&quot;</span><span class="pun" >);</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="kwd" >catch</span><span class="pln" > </span><span class="pun" >(</span><span class="pln" >android</span><span class="pun" >.</span><span class="pln" >content</span><span class="pun" >.</span><span class="typ" >ActivityNotFoundException</span><span class="pln" > ex</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="typ" >Toast</span><span class="pun" >.</span><span class="pln" >makeText</span><span class="pun" >(</span><span class="typ" >MainActivity</span><span class="pun" >.</span><span class="kwd" >this</span><span class="pun" >,</span><span class="pln" > </span><span class="str" >&quot;There is no email client installed.&quot;</span><span class="pun" >,</span><span class="pln" > </span><span class="typ" >Toast</span><span class="pun" >.</span><span class="pln" >LENGTH_SHORT</span><span class="pun" >).</span><span class="pln" >show</span><span class="pun" >();</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="lit" >@Override</span><span class="pln" > </span><span class="kwd" >public</span><span class="pln" > </span><span class="kwd" >boolean</span><span class="pln" > onCreateOptionsMenu</span><span class="pun" >(</span><span class="typ" >Menu</span><span class="pln" > menu</span><span class="pun" >)</span><span class="pln" > </span><span class="pun" >{</span><span class="pln" > </span><span class="com" >// Inflate the menu; this adds items to the action bar if it is present.</span><span class="pln" > getMenuInflater</span><span class="pun" >().</span><span class="pln" >inflate</span><span class="pun" >(</span><span class="pln" >R</span><span class="pun" >.</span><span class="pln" >menu</span><span class="pun" >.</span><span class="pln" >main</span><span class="pun" >,</span><span class="pln" > menu</span><span class="pun" >);</span><span class="pln" > </span><span class="kwd" >return</span><span class="pln" > </span><span class="kwd" >true</span><span class="pun" >;</span><span class="pln" > </span><span class="pun" >}</span><span class="pln" > </span><span class="pun" >}</span></pre> <p >Following will be the content of<b >res/layout/activity_main.xml</b>file &minus;</p> <pre class="prettyprint notranslate prettyprinted" > <span class="tag" >&lt;LinearLayout</span><span class="pln" > </span><span class="atn" >xmlns:android</span><span class="pun" >=</span><span class="atv" >&quot;http://schemas.android.com/apk/res/android&quot;</span><span class="pln" > </span><span class="atn" >android:layout_width</span><span class="pun" >=</span><span class="atv" >&quot;fill_parent&quot;</span><span class="pln" > </span><span class="atn" >android:layout_height</span><span class="pun" >=</span><span class="atv" >&quot;fill_parent&quot;</span><span class="pln" > </span><span class="atn" >android:orientation</span><span class="pun" >=</span><span class="atv" >&quot;vertical&quot;</span><span class="pln" > </span><span class="tag" >&gt;</span><span class="pln" > </span><span class="tag" >&lt;TextView</span><span class="pln" > </span><span class="atn" >android:id</span><span class="pun" >=</span><span class="atv" >&quot;@+id/textView1&quot;</span><span class="pln" > </span><span class="atn" >android:layout_width</span><span class="pun" >=</span><span class="atv" >&quot;wrap_content&quot;</span><span class="pln" > </span><span class="atn" >android:layout_height</span><span class="pun" >=</span><span class="atv" >&quot;wrap_content&quot;</span><span class="pln" > </span><span class="atn" >android:text</span><span class="pun" >=</span><span class="atv" >&quot;Sending Mail Example&quot;</span><span class="pln" > </span><span class="atn" >android:layout_alignParentTop</span><span class="pun" >=</span><span class="atv" >&quot;true&quot;</span><span class="pln" > </span><span class="atn" >android:layout_centerHorizontal</span><span class="pun" >=</span><span class="atv" >&quot;true&quot;</span><span class="pln" > </span><span class="atn" >android:textSize</span><span class="pun" >=</span><span class="atv" >&quot;30dp&quot;</span><span class="pln" > </span><span class="tag" >/&gt;</span><span class="pln" > </span><span class="tag" >&lt;TextView</span><span class="pln" > </span><span class="atn" >android:id</span><span class="pun" >=</span><span class="atv" >&quot;@+id/textView2&quot;</span><span class="pln" > </span><span class="atn" >android:layout_width</span><span class="pun" >=</span><span class="atv" >&quot;wrap_content&quot;</span><span class="pln" > </span><span class="atn" >android:layout_height</span><span class="pun" >=</span><span class="atv" >&quot;wrap_content&quot;</span><span class="pln" > </span><span class="atn" >android:text</span><span class="pun" >=</span><span class="atv" >&quot;Tutorials point &quot;</span><span class="pln" > </span><span class="atn" >android:textColor</span><span class="pun" >=</span><span class="atv" >&quot;#ff87ff09&quot;</span><span class="pln" > </span><span class="atn" >android:textSize</span><span class="pun" >=</span><span class="atv" >&quot;30dp&quot;</span><span class="pln" > </span><span class="atn" >android:layout_above</span><span class="pun" >=</span><span class="atv" >&quot;@+id/imageButton&quot;</span><span class="pln" > </span><span class="atn" >android:layout_alignRight</span><span class="pun" >=</span><span class="atv" >&quot;@+id/imageButton&quot;</span><span class="pln" > </span><span class="atn" >android:layout_alignEnd</span><span class="pun" >=</span><span class="atv" >&quot;@+id/imageButton&quot;</span><span class="pln" > </span><span class="tag" >/&gt;</span><span class="pln" > </span><span class="tag" >&lt;ImageButton</span><span class="pln" > </span><span class="atn" >android:layout_width</span><span class="pun" >=</span><span class="atv" >&quot;wrap_content&quot;</span><span class="pln" > </span><span class="atn" >android:layout_height</span><span class="pun" >=</span><span class="atv" >&quot;wrap_content&quot;</span><span class="pln" > </span><span class="atn" >android:id</span><span class="pun" >=</span><span class="atv" >&quot;@+id/imageButton&quot;</span><span class="pln" > </span><span class="atn" >android:src</span><span class="pun" >=</span><span class="atv" >&quot;@drawable/abc&quot;</span><span class="pln" > </span><span class="atn" >android:layout_centerVertical</span><span class="pun" >=</span><span class="atv" >&quot;true&quot;</span><span class="pln" > </span><span class="atn" >android:layout_centerHorizontal</span><span class="pun" >=</span><span class="atv" >&quot;true&quot;</span><span class="pln" > </span><span class="tag" >/&gt;</span><span class="pln" > </span><span class="tag" >&lt;Button</span><span class="pln" > </span><span class="atn" >android:id</span><span class="pun" >=</span><span class="atv" >&quot;@+id/sendEmail&quot;</span><span class="pln" > </span><span class="atn" >android:layout_width</span><span class="pun" >=</span><span class="atv" >&quot;fill_parent&quot;</span><span class="pln" > </span><span class="atn" >android:layout_height</span><span class="pun" >=</span><span class="atv" >&quot;wrap_content&quot;</span><span class="pln" > </span><span class="atn" >android:text</span><span class="pun" >=</span><span class="atv" >&quot;@string/compose_email&quot;</span><span class="tag" >/&gt;</span><span class="pln" > </span><span class="tag" >&lt;/LinearLayout&gt;</span></pre> <p >Following will be the content of<b >res/values/strings.xml</b>to define two new constants &minus;</p> <pre class="prettyprint notranslate prettyprinted" > <span class="pun" >&lt;?</span><span class="pln" >xml version</span><span class="pun" >=</span><span class="str" >&quot;1.0&quot;</span><span class="pln" > encoding</span><span class="pun" >=</span><span class="str" >&quot;utf-8&quot;</span><span class="pun" >?&gt;</span><span class="pln" > </span><span class="tag" >&lt;resources&gt;</span><span class="pln" > </span><span class="tag" >&lt;string</span><span class="pln" > </span><span class="atn" >name</span><span class="pun" >=</span><span class="atv" >&quot;app_name&quot;</span><span class="tag" >&gt;</span><span class="pln" >Tutorialspoint</span><span class="tag" >&lt;/string&gt;</span><span class="pln" > </span><span class="tag" >&lt;string</span><span class="pln" > </span><span class="atn" >name</span><span class="pun" >=</span><span class="atv" >&quot;hello_world&quot;</span><span class="tag" >&gt;</span><span class="pln" >Hello world!</span><span class="tag" >&lt;/string&gt;</span><span class="pln" > </span><span class="tag" >&lt;string</span><span class="pln" > </span><span class="atn" >name</span><span class="pun" >=</span><span class="atv" >&quot;action_settings&quot;</span><span class="tag" >&gt;</span><span class="pln" >Settings</span><span class="tag" >&lt;/string&gt;</span><span class="pln" > </span><span class="tag" >&lt;string</span><span class="pln" > </span><span class="atn" >name</span><span class="pun" >=</span><span class="atv" >&quot;compose_email&quot;</span><span class="tag" >&gt;</span><span class="pln" >Compose Email</span><span class="tag" >&lt;/string&gt;</span><span class="pln" > </span><span class="tag" >&lt;/resources&gt;</span></pre> <p >Following is the default content of<b >AndroidManifest.xml</b>:</p> <pre class="prettyprint notranslate prettyprinted" > <span class="pun" >&lt;?</span><span class="pln" >xml version</span><span class="pun" >=</span><span class="str" >&quot;1.0&quot;</span><span class="pln" > encoding</span><span class="pun" >=</span><span class="str" >&quot;utf-8&quot;</span><span class="pun" >?&gt;</span><span class="pln" > </span><span class="tag" >&lt;manifest</span><span class="pln" > </span><span class="atn" >xmlns:android</span><span class="pun" >=</span><span class="atv" >&quot;http://schemas.android.com/apk/res/android&quot;</span><span class="pln" > </span><span class="atn" >package</span><span class="pun" >=</span><span class="atv" >&quot;com.example.Tutorialspoint&quot;</span><span class="pln" > </span><span class="atn" >android:versionCode</span><span class="pun" >=</span><span class="atv" >&quot;1&quot;</span><span class="pln" > </span><span class="atn" >android:versionName</span><span class="pun" >=</span><span class="atv" >&quot;1.0&quot;</span><span class="pln" > </span><span class="tag" >&gt;</span><span class="pln" > </span><span class="tag" >&lt;application</span><span class="pln" > </span><span class="atn" >android:allowBackup</span><span class="pun" >=</span><span class="atv" >&quot;true&quot;</span><span class="pln" > </span><span class="atn" >android:icon</span><span class="pun" >=</span><span class="atv" >&quot;@drawable/ic_launcher&quot;</span><span class="pln" > </span><span class="atn" >android:label</span><span class="pun" >=</span><span class="atv" >&quot;@string/app_name&quot;</span><span class="pln" > </span><span class="atn" >android:theme</span><span class="pun" >=</span><span class="atv" >&quot;@style/AppTheme&quot;</span><span class="pln" > </span><span class="tag" >&gt;</span><span class="pln" > </span><span class="tag" >&lt;activity</span><span class="pln" > </span><span class="atn" >android:name</span><span class="pun" >=</span><span class="atv" >&quot;com.example.tutorialspoint.MainActivity&quot;</span><span class="pln" > </span><span class="atn" >android:label</span><span class="pun" >=</span><span class="atv" >&quot;@string/app_name&quot;</span><span class="pln" > </span><span class="tag" >&gt;</span><span class="pln" > </span><span class="tag" >&lt;intent-filter&gt;</span><span class="pln" > </span><span class="tag" >&lt;action</span><span class="pln" > </span><span class="atn" >android:name</span><span class="pun" >=</span><span class="atv" >&quot;android.intent.action.MAIN&quot;</span><span class="pln" > </span><span class="tag" >/&gt;</span><span class="pln" > </span><span class="tag" >&lt;category</span><span class="pln" > </span><span class="atn" >android:name</span><span class="pun" >=</span><span class="atv" >&quot;android.intent.category.LAUNCHER&quot;</span><span class="pln" > </span><span class="tag" >/&gt;</span><span class="pln" > </span><span class="tag" >&lt;/intent-filter&gt;</span><span class="pln" > </span><span class="tag" >&lt;/activity&gt;</span><span class="pln" > </span><span class="tag" >&lt;/application&gt;</span><span class="pln" > </span><span class="tag" >&lt;/manifest&gt;</span></pre> <p >Let&#39;s try to run your<b >tutorialspoint</b>application. I assume you have connected your actual Android Mobile device with your computer. To run the app from Android Studio, open one of your project&#39;s activity files and click Run<img alt="Eclipse Run Icon" class="inline" src="http://www.tutorialspoint.com/android/images/eclipse_run.jpg" />icon from the toolbar. Before starting your application, Android studio installer will display following window to select an option where you want to run your Android application.Select your mobile device as an option and then check your mobile device which will display following screen &minus;</p> <p><img alt="Android Mobile Device" src="http://www.tutorialspoint.com/android/images/email1.jpg" /></p> <p >Now use<b >Compose Email</b>button to list down all the installed email clients. From the list, you can choose one of email clients to send your email. I&#39;m going to use Gmail client to send my email which will have all the provided defaults fields available as shown below. Here<b >From:</b>will be default email ID you have registered for your Android device.</p> <p><img alt="Android Mobile Gmail Screen" src="http://www.tutorialspoint.com/android/images/email2.jpg" /></p> <p >You can modify either of the given default fields and finally use send email button to send your email to the mentioned recipients.</p>
RangeTime:0.007902s
RangeMem:235.52 KB
返回顶部 留言