zoukankan      html  css  js  c++  java
  • Android 直接拨打电话界面

    Android 拨号界面和直接拨打电话界面代码控制

    //定义TAG为空

    private static final String TAG = null;

    //定义Button的点击事件

    tell.setOnClickListener(new View.OnClickListener() {
      
      @Override
      public void onClick(View v) {
       // TODO Auto-generated method stub
     /*  Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+10086));
       
       startActivity(intent);*/
       
       
        //直接拨打 
       
       String tel = "10086";
             call(tel);
      }
     });

    //点击事件调用的类

    protected void call(String tel) { 
      /*      // 只进入拨号界面,不拨打 
             Uri uri = Uri.parse("tel:" + tel); 
             Intent intent = new Intent(Intent.ACTION_DIAL, uri); 
             startActivity(intent);  */
     
             //直接拨打 
            Log.d(TAG, "call:" + tel); 
            Uri uri = Uri.parse("tel:" + tel); 
            Intent intent = new Intent(Intent.ACTION_CALL, uri); 
            startActivity(intent); 
        } 

    注意: 添加权限:

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

  • 相关阅读:
    vim命令总结
    SQL语句中----删除表数据drop、truncate和delete的用法
    备份数据工具类
    JavaWeb之 JSP:自定义标签
    Android studio安装与配置
    Redis 从入门到放弃
    java相关网址汇总2
    java相关网址汇总1
    校验字符串编码工具类
    java相关网址汇总(myself)
  • 原文地址:https://www.cnblogs.com/weixuexi/p/4910469.html
Copyright © 2011-2022 走看看