public static void call(BaseActivity activity, String phone) {
   if (TextUtils.isEmpty(phone)) {
     return;
   }
   DialContentView.isRefreshData = true;
   CallRecordsContentView.isRefreshData = true;
   Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
   activity.startActivity(intent);
 }
 /** 重置手势密码 */
 public static void resetGesture(BaseActivity activity) {
   if (BaseContext.getSharedPreferences().getBoolean(Preferences.SP_IS_RESET_LOCK_KEY, false)) {
     activity.startActivity(new Intent(activity, LockSetupActivity.class));
     BaseContext.getSharedPreferences().putBoolean(Preferences.SP_IS_RESET_LOCK_KEY, false);
   }
 }
 @Override
 public void onCallStateChanged(int state, String incomingNumber) {
   switch (state) {
     case TelephonyManager.CALL_STATE_OFFHOOK:
       IDLE = true;
       if (myFV == null) {
         wm =
             (WindowManager)
                 currentActivity.getAppContext().getSystemService(Context.WINDOW_SERVICE);
         View view =
             LayoutInflater.from(currentActivity.getAppContext())
                 .inflate(R.layout.module_diallistener, null);
         ImageView ivClose = (ImageView) view.findViewById(R.id.dial_listener_btn_close);
         ivClose.setOnClickListener(
             new View.OnClickListener() {
               @Override
               public void onClick(View v) {
                 // 关闭悬浮窗口
                 if (wm != null && myFV != null) {
                   wm.removeView(myFV);
                   myFV = null;
                 }
               }
             });
         TextView tvMessage = (TextView) view.findViewById(R.id.dial_listener_text);
         tvMessage.setText("您正在与" + SP_CALL_DIAL + "录音通话中…");
         myFV = new DialFloatView(currentActivity.getAppContext());
         myFV.addView(view);
         // 设置LayoutParams(全局变量)相关参数
         WindowManager.LayoutParams wmParams = myFV.getMywmParams();
         // 设置window type
         wmParams.type = LayoutParams.TYPE_PHONE;
         // 设置图片格式,效果为背景透明
         wmParams.format = PixelFormat.RGBA_8888;
         // 设置Window flag
         wmParams.flags =
             LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_NOT_FOCUSABLE;
         // 调整悬浮窗口至左上角
         wmParams.gravity = Gravity.LEFT | Gravity.TOP;
         // 以屏幕左上角为原点,设置x、y初始值
         wmParams.x = 0;
         wmParams.y = 0;
         // 设置悬浮窗口长宽数据
         wmParams.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
         wmParams.height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
         // 显示myFloatView图像
         wm.addView(myFV, wmParams);
       }
       break;
     case TelephonyManager.CALL_STATE_IDLE:
       // 拨打电话状态顺序1.CALL_STATE_IDLE 2.CALL_STATE_OFFHOOK
       // 3.CALL_STATE_IDLE由于只需要取最后一个CALL_STATE_IDLE所以在这里需要一个逻辑判断
       if (IDLE) {
         IDLE = false;
         // 停止监听手机通话状态
         if (manager != null) {
           manager.listen(stateListener, PhoneStateListener.LISTEN_NONE);
         }
         // 通话结束后关闭悬浮窗口
         if (wm != null && myFV != null) {
           wm.removeView(myFV);
           myFV = null;
         }
         // 设置拨打的号码为空
         BaseContext.getSharedPreferences()
             .putString(Constant.Preferences.SP_CALL_DIAL, AppConstant.EMPTYSTR);
         ActivityManager am =
             (ActivityManager) currentActivity.getSystemService(Context.ACTIVITY_SERVICE);
         ComponentName cn = am.getRunningTasks(1).get(0).topActivity;
         if (!cn.getClassName().equals(MainActivity.class.getName())) {
           // Android4.0以上系统默认打完电话后会跳转到
           Intent intent = new Intent(currentActivity, MainActivity.class);
           intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
           currentActivity.startActivity(intent);
         }
       }
       break;
   }
 }