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"/> 

  • 相关阅读:
    文件操作
    join,列表和字典用for循环的删除,集合,深浅拷贝
    java多线程基础
    nginx应用及性能调优
    nginx 基本功能
    SpringBoot2.x 启动过程详解
    shell脚本的基本使用
    使用 maven 的 `wagon-maven-plugin`插件 快速部署 到不同的 环境
    Netty笔记(7)
    Netty笔记(6)
  • 原文地址:https://www.cnblogs.com/weixuexi/p/4910469.html
Copyright © 2011-2022 走看看