android自动拨打电话

来源:互联网 发布:淘宝怎么找达人推广 编辑:程序博客网 时间:2024/04/30 10:21

1. Create Android Application Project

2. In MainActivity.java, add the below:


package com.example.testandroid1;


import android.app.Activity;
import android.content.Intent;

       class MainActivity extends Activity {

.....  

     public void onButtonClick(View v)
      {
          Intent intent =new Intent(Intent.ACTION_CALL,Uri.parse("tel:110"));
          MainActivity.this.startActivity(intent);

       }

}

3. In AndroidManifest.xml, add the below. Its level is same as <uses-sdk>

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

4. Right click the project and choose Run as -> Android Device Chooser ->Choose device






0 0
原创粉丝点击