1

단추의 onClick() 메서드로 이루어진 나가는 호출을 잘라낼 때 어떻게 되나요? 나는 대화 상자를 열고있는 곳의 조각이있는 단추가 있습니다. 대화 상자의 버튼 클릭 전화 통화 활동이 여기 을 시작에 내가 몇 가지 코드를 넣어 내 전화 상태 리스너는 친절하게 나에게사용자가 나가는 호출을자를 때 같은 조각으로 돌아갈 수있는 방법

// 전화했다

String temp = "tel:+91"+"xxxxxxxxxx"; 
        Intent callIntent = new Intent(Intent.ACTION_CALL); 
        callIntent.setData(Uri.parse(temp)); 
        startActivity(callIntent); 

// 내 전화 상태 리스너

private class PhoneCallStateListener extends PhoneStateListener 
    { 
    private boolean isSystemCalling = false; 
     public void onCallStateChanged(int state, String incomingNumber) { 
      if (TelephonyManager.CALL_STATE_OFFHOOK == state) 
      { 
       isSystemCalling = true; 
      } 
      if (TelephonyManager.CALL_STATE_IDLE == state) 
      { 
       if (isSystemCalling) 
       { 
        if(!active) 
        { 
         db.update_activity(Utilities.CONST_SYS_STATUS,Utilities.STATUS_DEACTIVE); 
         update(); 
        } 
        else 
        { 
db.update_activity(Utilities.CONST_SYS_STATUS,Utilities.STATUS_ACTIVE); 
         update(); 
        } 
        isSystemCalling = false; 
       } 
      } 
     } 
    } 
도움

답변

0

아래 코드를 사용 했으므로 원하는대로 작동합니다. 전화 한 후 돌아오고 있습니다.

Uri number = Uri.parse("tel:" + contactNumber); 
Intent dial = new Intent(Intent.ACTION_CALL, number); 
if (ActivityCompat.checkSelfPermission(mContext, android.Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { 
           // TODO: Consider calling 
           // ActivityCompat#requestPermissions 
           // here to request the missing permissions, and then overriding 
           // public void onRequestPermissionsResult(int requestCode, String[] permissions, 
           //           int[] grantResults) 
           // to handle the case where the user grants the permission. See the documentation 
           // for ActivityCompat#requestPermissions for more details. 
    return; 
} 
mContext.startActivity(dial); 

작동하는 경우 사용해보세요.

+0

예, 제대로 작동하지 않습니다.이 줄 앞에 startActivity (callIntent); 권리 ? –

+0

예, 코드로 이해할 수있는 한 실수였습니다. 어쨌든, 당신의 problem.Keep 코딩을 해결하면 답변을 허용으로 표시 할 수 있습니다 :) @ravi_koriya – Swr7der

관련 문제