'Call'에 해당되는 글 2건

  1. 2023.08.22 [Android][Kotlin] Call 발신 하기
  2. 2017.06.15 [Android] ADB로 전화 걸기
Tip/Android2023. 8. 22. 23:34

AndroidManifest.xml에 아래와 같이 권한을 추가 한다

    <uses-feature
        android:name="android.hardware.telephony"
        android:required="false" />

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

 MainActivity안에 아래와 같이 버튼에 이벤트를 연결한다.

    private fun init() {
        val callButton : Button = findViewById(R.id.callButton)
        callButton.setOnClickListener( View.OnClickListener { _ -> runCall() })
    }

    private fun runCall() {
        val intent = Intent(Intent.ACTION_CALL, Uri.parse("tel:01234561492"))
        val status = ActivityCompat.checkSelfPermission(this, 
            android.Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED
        if (status) {
            startActivity(intent)
        } else {
            Log.i("TAG", "Unable to launch call");
            ActivityCompat.requestPermissions(this, 
                arrayOf<String>(android.Manifest.permission.CALL_PHONE), CALL_REQUEST)
        }
    }

아래와 같이 onRequestPermissionsReseult()를 오버라이딩 해주면, 권한 컨펌 즉시 콜이 걸리게 된다.

    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<out String>,
        grantResults: IntArray
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        when (requestCode) {
            CALL_REQUEST -> {
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    Toast.makeText(this, "통화가 가능 합니다", Toast.LENGTH_LONG).show()
                    runCall()
                } else {
                    Toast.makeText(this, "통화가 거절 되었습니다", Toast.LENGTH_LONG).show()
                }
            }
        }
    }
Posted by chobocho
Coding/Tip2017. 6. 15. 00:51

[전화걸기]

adb shell am start -a android.intent.action.CALL -d tel:123-4567


[통화종료]

adb shell input keyevent KEYCODE_ENDCALL

or

adb shell input keyevent 6


[전화수신]

adb shell input keyevent 5


[5초간 대기 - DOS command]

timeout /t 5



[ 전화를 걸고 10초 뒤에 종료하는 스크립트 ]

adb shell am start -a android.intent.action.CALL -d tel:123-4567

timeout /t 10

adb shell input keyevent KEYCODE_ENDCALL




[ 자료출처 ]

https://stackoverflow.com/questions/4923550/how-to-make-a-call-via-pc-by-adb-command-on-android

https://stackoverflow.com/questions/25587147/adb-command-to-cancel-hang-up-incoming-call

https://stackoverflow.com/questions/166044/sleeping-in-a-batch-file

Posted by chobocho