Phone Dialer App Learning

Source: Internet
Author: User

This thought is a simple telephone dialer, or learned a lot of things, so still learned a lot of things, understand the Android permissions Uri.parse several uses:

Not much to say on the code:

Package Com.djf.phone;import Android.app.activity;import Android.content.intent;import android.net.Uri;import Android.os.bundle;import Android.text.textutils;import Android.view.view;import Android.widget.EditText;import Android.widget.toast;public class Mainactivity extends Activity {@Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main);} public void Myclick (view view) {EditText Medittext = (EditText) Findviewbyid (R.id.et_number); String number = Medittext.gettext (). toString (). Trim (); Boolean result = Textutils.isempty (number); if (result) { Toast.maketext (This, "phone number is empty", 0). Show (); else {Intent Intent = new Intent (); intent.setaction (Intent.action_call);  Intent.setdata (Uri.parse ("Tel:" +number)); StartActivity (intent);}}}

The above red part mainly involves several usages of uri.prase

"Tel:" must not omit

The following is an important usage of uri.prase

1, tune the Web browser
Uri Mybloguri = Uri.parse ("http://xxxxx.com");
Returnit = new Intent (Intent.action_view, Mybloguri);
2, Map
Uri Mapuri = Uri.parse ("geo:38.899533,-77.036476");
Returnit = new Intent (Intent.action_view, Mapuri);
3, transfer the phone interface
Uri Teluri = Uri.parse ("tel:100861");
Returnit = new Intent (intent.action_dial, Teluri);
4, call directly
Uri Calluri = Uri.parse ("tel:100861");
Returnit = new Intent (Intent.action_call, Calluri);
5, uninstall
Uri Uninstalluri = uri.fromparts ("package", "XXX", null);
Returnit = new Intent (Intent.action_delete, Uninstalluri);
6, installation
Uri Installuri = uri.fromparts ("package", "XXX", null);
Returnit = new Intent (intent.action_package_added, Installuri);
7, play
Uri Playuri = Uri.parse ("File:///sdcard/download/everything.mp3");
Returnit = new Intent (Intent.action_view, Playuri);
8, call Send Message
Uri Emailuri = Uri.parse ("Mailto:[email protected]");
Returnit = new Intent (intent.action_sendto, Emailuri);
9, send e-mail
Returnit = new Intent (intent.action_send);
String[] tos = {"[Email protected]"};
String[] CCS = {"[Email protected]"};
Returnit.putextra (Intent.extra_email, TOS);
Returnit.putextra (INTENT.EXTRA_CC, CCS);
Returnit.putextra (Intent.extra_text, "body");
Returnit.putextra (Intent.extra_subject, "SUBJECT");
Returnit.settype ("message/rfc882");
Intent.createchooser (Returnit, "Choose Email Client");
10, send SMS
Uri Smsuri = Uri.parse ("tel:100861");
Returnit = new Intent (Intent.action_view, Smsuri);
Returnit.putextra ("Sms_body", "yyyy");
Returnit.settype ("vnd.android-dir/mms-sms");
11, send mail directly
Uri Smstouri = Uri.parse ("smsto://100861");
Returnit = new Intent (intent.action_sendto, Smstouri);
Returnit.putextra ("Sms_body", "yyyy");
12, send MMS
Uri Mmsuri = Uri.parse ("Content://media/external/images/media/23");
Returnit = new Intent (intent.action_send);
Returnit.putextra ("Sms_body", "yyyy");
Returnit.putextra (Intent.extra_stream, Mmsuri);
Returnit.settype ("Image/png");

Phone Dialer App Learning

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.