1

I am building a Voip app in android. Everything is working fine but I am not able to figure out how to accept and reject calls.

I use TelephoneManager#addNewIncomingCall to report new calls to the system. After that, I created a Connection object in ConnectionService#onCreateIncomingConnection and returned it. The onShowIncomingCallUi gets called and I create a notification this way:

        val intent = Intent(context, TokboxActivity::class.java).apply {
            flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
            this.putExtras(this@Call.extras)
        }

        val pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)

        val notification = NotificationCompat.Builder(context, "OKDOK")
                .setSmallIcon(R.drawable.common_full_open_on_phone)
                .setContentTitle("OKDOK")
                .setContentText("Incoming call from ${extras.getString("docName")}")
                .setPriority(NotificationCompat.PRIORITY_MAX)
                .setCategory(NotificationCompat.CATEGORY_CALL)
                .setFullScreenIntent(pendingIntent, true)
                .build()

        notification.flags = notification.flags or NotificationCompat.FLAG_INSISTENT

        val notificationManager = context.getSystemService(
                NotificationManager::class.java)
        notificationManager.notify("OKDOK", 0, notification)

I am getting the notification too. But I have two buttons in TokboxActivity. I want them to accept and reject the call. How do I implement that?

  • See https://stackoverflow.com/questions/63637981/how-can-an-android-activity-communicate-with-a-connectionservice-implementation – Daniel Salvadori Aug 28 '20 at 16:59
  • I am also implementing that but in my case onShowIncomingCallUi not called. how did you manage to call that method? deatils :- https://stackoverflow.com/q/76217191/12529245 – Mohammad Taqi May 11 '23 at 05:22

0 Answers0