Android app Simple Phone Dialer

Source: Internet
Author: User
Tags gettext

Implementation steps:

1. Drawing the UI

You can use drag-and-drop and text editing.

2. Write business logic according to UI in OnCreate in Mainactivity

Get EditText Contentet_number = (editText) Findviewbyid (R.ID.EDITTEXT1);//find zhe Buttonbutton btn_call = (Button) Findviewbyid (R.id.button);    

3. Set a click event inner class for the button

New  MyListener ()); in//oncreate
  Private classMyListenerImplementsview.onclicklistener{ Public voidOnClick (View v) {String number=Et_number.gettext (). toString (). Trim (); if("". Equals (number)) {Toast.maketext (mainactivity). This, "Please enter the number you want to dial", Toast.length_short). Show (); return; } Intent Intent=NewIntent ();            Intent.setaction (Intent.action_call); Intent.setdata (Uri.parse ("Tel:" +Number ));        StartActivity (Intent); }    }

4. Set a click event Hide class for the button

Btn_call.setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (View v) {String number=Et_number.gettext (). toString (). Trim (); if("". Equals (number)) {Toast.maketext (mainactivity). This, "Please enter the number you want to dial", Toast.length_short). Show (); return; } Intent Intent=NewIntent ();                Intent.setaction (Intent.action_call); Intent.setdata (Uri.parse ("Tel:" +Number ));            StartActivity (Intent); }        });

5. Set a click event for the button to implement the interface type in the current class

6. Set a click event for the button

7. Plus the right to call

<uses-permission android:name= "Android.permission.CALL_PHONE"/>

End

Android app Simple Phone Dialer

Related Article

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.