Android 点击电话号码之间拨号

 

  点击电话号码之间拨打电话,可用通过下面的方式实现: 假设电话号码以TextView的方式显示

 1、Intent方式

   在TextView的响应事件中 :

      

String phone = tvphone.getText().toString();
Intent i = new Intent();
i.setAction(Intent.ACTION_DIAL);
i.setData(Uri.parse("tel:"+phone));

  

     注意:action 类型为 Intent.ACTION_DIAL,无需任何权限。

  点击后出现拨号页面:

 

 第二种方式: 修改Intent 的ACTION 类型为:Intent.ACTION_CALL ,代码同上。需要在AndroidMainfest.xml中添加权限:

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

点击事件后不会出现拨号页面,直接呼出。

2. 通过设置TextView中的属性:android:autoLink="phone"

 

posted @ 2016-08-17 17:15  googlg  阅读(586)  评论(0编辑  收藏  举报