首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何显示Agora 1到1视频呼叫应用程序的来电通知

问如何显示Agora 1到1视频呼叫应用程序的来电通知
EN

Stack Overflow用户
提问于 2019-10-15 04:34:27
回答 1查看 5.9K关注 0票数 1

既然Agora是通过创建一个通道来工作的,那么如何才能向另一个用户显示有一个调用。我认为一种方法是创建一个服务,它将使用改造来监听服务器,如果调用状态发生变化,我将向他展示,但在安卓系统中,后台服务是受限的。另一种我认为是通过创建一个带有调度程序的广播接收器的方法。有人能帮上忙吗。

代码语言:javascript
复制
class CallReciever : BroadcastReceiver() {
    val REQUEST_CODE : Int= 12345
    val ACTION :String= "com.codepath.example.servicesdemo.alarm"
    override fun onReceive(context: Context, intent: Intent) {
        val i = Intent(context, MyTestService::class.java)
        startWakefulService(context, i)
    }
}
代码语言:javascript
复制
class MyTestService : IntentService("MyTestService") {

    override fun onHandleIntent(intent: Intent?) {
        // Do the task here
       getBanner()
    }
    private fun getBanner() {

        val service = RetrofitCall.provideRetrofit().create(callrecieveAPI::class.java)
        val call = service.banner()

        call.enqueue(object : Callback<CallReceivePOJO> {
            override fun onResponse(call: Call<CallReceivePOJO>, response: Response<CallReceivePOJO>) {
                //showFailureDialog(GuestCheckoutActivity.this, response.body().getMessage());

                CommonObjects.channelid =response.body()!!.data.toString()

            }

            override fun onFailure(call: Call<CallReceivePOJO>, t: Throwable) {
                // handle execution failures like no internet connectivity

            }
        })

    }
}
代码语言:javascript
复制
class SplashActivity : AppCompatActivity() {

     override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash)
        scheduleAlarm()
        object : CountDownTimer(5000, 1000) {
            override fun onFinish() { 
                     intent = Intent(applicationContext, VideoChatViewActivity::class.java)
                    startActivity(intent)

            }

            override fun onTick(p0: Long) {}
        }.start()
    }


    fun scheduleAlarm() {
        // Construct an intent that will execute the AlarmReceiver
        val intent = Intent(applicationContext, CallReciever::class.java)
        // Create a PendingIntent to be triggered when the alarm goes off
        val pIntent = PendingIntent.getBroadcast(
            this, REQUEST_CODE,
            intent, PendingIntent.FLAG_UPDATE_CURRENT
        )
        // Setup periodic alarm every every half hour from this point onwards
        val firstMillis = System.currentTimeMillis() // alarm is set right away
        val alarm = this.getSystemService(Context.ALARM_SERVICE) as AlarmManager
        // First parameter is the type: ELAPSED_REALTIME, ELAPSED_REALTIME_WAKEUP, RTC_WAKEUP
        // Interval can be INTERVAL_FIFTEEN_MINUTES, INTERVAL_HALF_HOUR, INTERVAL_HOUR, INTERVAL_DAY
        alarm.setInexactRepeating(
            AlarmManager.RTC_WAKEUP, firstMillis,
            10000, pIntent
        )
    }
EN

回答 1

Stack Overflow用户

发布于 2019-12-12 15:15:20

Agora有一些示例应用程序,展示了如何使用Agora的视频和实时消息SDK以及本地API(Android的ConnectionService和iOS的CallKit)实现“调用”功能。

安卓:https://github.com/AgoraIO-Usecase/Video-Calling/tree/master/OpenDuo-Android

IOS:https://github.com/AgoraIO-Usecase/Video-Calling/tree/master/OpenDuo-iOS

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58387319

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档