Use the phone number stored in your phone to call and send a message to your contacts.

Source: Internet
Author: User

1. The data stored in the database layout to the phone interface, the operation please see http://blog.csdn.net/xia09222826/article/details/28660653

2. The three effects show the following effects:

1) Custom Effects


2) Single-radio effect

3) Multi-selection effect

3. Tap a contact to make a call or send a text message (for example, a custom effect)

1) Effect view (e.g. click on the number 1 contact): From the phone phone backup interface to jump to the Phoneandemailactitvity interface

2) Program implementation

① Register Click event Lv_users.setonitemclicklistener (this);

② uses Getitematposition () in the Onitemclick () method to obtain data based on location, using intent intent=new intent (mainactivity.this, Phoneandemailactivity.class); From the mobile phone backup interface to the Phoneandemailactitvity interface, use Putextra () method to get the information you want to pass to the Phoneandemailactitvity interface.

Note: You need to use startactivity (intent); Start activity

③ in Phoneandemailactitvity, the use of Intent intent=getintent (); String name = Intent.getstringextra ("username"); final string phone = Intent.getstringextra ("Userphone"); Get information that is passed from the phone backup interface

3) The realization of the function of dialing the telephone

① Create a Click event for a phone call button:

Tv_call.setonclicklistener (New View.onclicklistener () {@Overridepublic void OnClick (View v) {Intent intent=new Intent ( Intent.action_call,uri.parse ("Tel:" +phone)); PhoneandemailActivity.this.startActivity (intent);}});

② the interface shown after clicking is:

4) The implementation of the function of sending SMS

① Create a Click event to send a text message and use the intent object to pass the contact's number to the Messageactivity interface

Tv_massage.setonclicklistener (New View.onclicklistener () {@Overridepublic void OnClick (View v) {Intent intent=new Intent (Phoneandemailactivity.this, Massageactivity.class); Intent.putextra ("Userphone", phone); StartActivity ( Intent);});

The construction of ②messageactivity interface


③ program implementation of the function of sending SMS

A. Use the intent object to get the information passed through the Phoneandemailactitvity interface.

B. Create a sent Click event Send_btn.setonclicklistener (this);

@Overridepublic void OnClick (View v) {int id=v.getid (); switch (ID) {Case r.id.send_btn:string Phonenum=et_phone.gettext (). toString (); String Content=et_content.gettext (). toString (); if (Textutils.isempty (content)) {Toast.maketext (this, R.string.error_sms_content, Toast.length_short). Show ();} Else{smsmanager Smsmanager=smsmanager.getdefault (); Arraylist<string> message = smsmanager.dividemessage (content); for (int i=0;i<message.size (); i++) { Smsmanager.sendtextmessage (Phonenum, Null,message.get (i), NULL, NULL);} Toast.maketext (This, r.string.success_sms_content, Toast.length_long). Show ();} Break;default:break;}
C. Achieving results
 

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.