Я' Я включил мой AndroidManifest.xml и соответствующий код для MainActivity и MyCustomCallScreeningService ниже для справки.
AndroidManifest.xml:
Код: Выделить всё
Код: Выделить всё
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
requestRole()
}
private val REQUEST_ID = 1
fun requestRole() {
val roleManager = getSystemService(Context.ROLE_SERVICE) as RoleManager
val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_CALL_SCREENING)
startActivityForResult(intent, REQUEST_ID)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == REQUEST_ID) {
if (resultCode == android.app.Activity.RESULT_OK) {
println("Your app is now the call screening app")
} else {
println("Your app is not the call screening app")
}
}
}
}
Код: Выделить всё
class MyCustomCallScreeningService: CallScreeningService() {
override fun onScreenCall(callDetails: Call.Details) {
System.out.println("Should print this message when there is an incoming call")
respondToCall(callDetails, CallResponse.Builder().build())
}
}
Подробнее здесь: https://stackoverflow.com/questions/773 ... g-galaxy-s