In Android, how do I call a call?

Source: Internet
Author: User

The Android system was originally designed for mobile phones. Therefore, it is very convenient to call a specified phone number in any android App.
The core is to use Intent jump, and specify the request Action as Intent. ACTION_CALL.

 

The core code is as follows:

1 Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse(tel:13888888888);

The following describes how to implement this function:

Step 2: Create an activity: DialerAndMsgActivity

package com.android.dev;import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText;public class DialerAndMsgActivity extends Activity { private Button dialerButton; private EditText editTextPhoneNum;/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);dialerButton = (Button) findViewById(R.id.Button_Dialer); editTextPhoneNum = (EditText) findViewById(R.id.EditText_PhoneNum);dialerButton.setOnClickListener(new View.OnClickListener(){public void onClick(View arg0) { Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse(tel:+ editTextPhoneNum.getText())); DialerAndMsgActivity.this.startActivity(intent); }}); } }


Step 2: modify the configuration file main. xml

 

 
  
  
  
   
    
   
  
 

 

Step 2: Add dialing support in the configuration file AndroidManifest. xml

1 <uses-permission android:name=android.permission.CALL_PHONE> uses-permission>

4th trial run:

Android dialing

Android dialing

 

[Source code download] http://www.code4apk.com/android-code/178

 

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.