Android SMS send feature

Source: Internet
Author: User
Tags gettext

XML File Code section

<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"      xmlns:tools= "Http://schemas.android.com/tools"     android:layout_width= "Match_parent"     android:layout_height= "Match_parent"     android:padding= "10DP"  ><edittext     android:id= "@+id/phonenum"     android: Layout_width= "Match_parent"     android:layout_height= "Wrap_content"      android:hint= "Please enter your mobile phone number"     /><edittext     android:id= "@+id/duanxin"     android:layout_width= "Match_parent"     android: layout_height= "200px"     android:hint= "Please enter the SMS to be sent"     android:layout_ below= "@id/phonenum"     /><button     android:id= "@+id/ Fasong "    android:Layout_width= "Wrap_content"     android:layout_height= "Wrap_content"      android:text= "Send"     android:layout_below= "@id/duanxin"      Android:layout_alignparentright= "true"     /></RelativeLayout>
Public class mainactivity extends activity {private edittext phonenum, duanxin;private button button;     @Override     protected  void oncreate (bundle savedinstancestate)  {         super.oncreate (savedinstancestate);         setcontentview ( R.layout.activity_main);         phonenum= (EditText) findViewById ( R.id.phonenum);         duanxin= (EditText) Findviewbyid (R.id.duanxin);         button= (Button) Findviewbyid (R.id.fasong);         butlis lis=new butlis ();         button.setonclicklistener (LIS);             }     class butlis implements onclicklistener{     @Override     public void  onclick (view v)  {    new thread (new runnable ()  {@ Overridepublic void run ()  {// TODO Auto-generated method stubString  Num=phonenum.gettext (). toString ();     smsmanager sms=smsmanager.getdefault ();     sms.sendtextmessage (Num, null, duanxin.gettext (). toString (),  null, null) ;}}). Start ();                             }    }


This article is from the "Java White Battlefield" blog, be sure to keep this source http://8023java.blog.51cto.com/10117207/1663709

Android SMS send feature

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.