首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

Intent.ACTION.CALL拨通电话

2012-07-28 
Intent.ACTION.CALL拨打电话添加权限?uses-permission android:nameandroid.permission.CALL_PHONE/

Intent.ACTION.CALL拨打电话

添加权限

?

<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission><!-- 放在application标签之外-->

?

private Button mButton1;private EditText mEditText1;public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.telephone);mEditText1 = (EditText) findViewById(R.id.editText1);mButton1 = (Button) findViewById(R.id.button1);/* 设定Button对象的OnClickListener来聆听OnClick事件 */mButton1.setOnClickListener(new Button.OnClickListener() {public void onClick(View v) {try {/* 取得EditText中用户输入的字符串 */String strInput = mEditText1.getText().toString();/* 建构一个新的Intent并执行action.CALL的常数与透过Uri将字符串带入 */Intent myIntentDial = new Intent("android.intent.action.CALL", Uri.parse("tel:"+ strInput));/* 在startActivity()方法中带入自定义的Intent对象以执行拨打电话的工作 */startActivity(myIntentDial);mEditText1.setText("");} catch (Exception e) {e.printStackTrace();}}});}
?

Intent.ACTION.CALL拨通电话
?
Intent.ACTION.CALL拨通电话

?

转跳至通讯录

1.添加权限

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

或者需要允许的权限

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

?

2.代码

?

Intent myIntentDial = new Intent("android.intent.action.CALL_BUTTON");         startActivity(myIntentDial);
?

?

热点排行