android 电话拨号器


android 电话拨号器 配置什么的 就不那么废话了,直接说关键代码

 String number  = mobileText.getText().toString();
 Intent intent = new Intent();//创建意图
  intent.setAction("android.intent.action.CALL");
  intent.setCategory("android.intent.category.DEFAULT");
  intent.setData(Uri.parse("tel:"+number));
  startActivity(intent);//这个方法会自动为intent添加类别,所以 此时就不需要---intent.setCategory("android.intent.category.DEFAULT");-- 


在清单文件中添加相应权限
 <uses-permission android:name="android.permission.CALL_PHONE"/>

猜你喜欢

转载自annan211.iteye.com/blog/1933924