Agora.io 使用Agora SDK进行视频通话时发出颤振通知

Agora.io 使用Agora SDK进行视频通话时发出颤振通知,agora.io,Agora.io,我是个新手。我正在用视频SDK开发一个应用程序。我想知道的是,当你在视频通话中,按下home(主页)按钮时,应用程序在后台运行,当时我想显示一个通知“你正在视频通话”,单击时需要打开应用程序。有谁能帮我获取应用程序的状态,以及该应用程序是否在后台运行、是否处于非活动状态或是否已被完全销毁,我们使用了WidgetSBindingObserver和我们将其与AppLifecycleState结合使用 因此,您的代码将如下所示: class _MyHomePageState extends State

我是个新手。我正在用视频SDK开发一个应用程序。我想知道的是,当你在视频通话中,按下home(主页)按钮时,应用程序在后台运行,当时我想显示一个通知“你正在视频通话”,单击时需要打开应用程序。有谁能帮我获取应用程序的状态,以及该应用程序是否在后台运行、是否处于非活动状态或是否已被完全销毁,我们使用了
WidgetSBindingObserver和
我们将其与
AppLifecycleState
结合使用

因此,您的代码将如下所示:

class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver{
  @override
  void initState() { 
    super.initState();
    WidgetsBinding.instance.addObserver(this);
  }
  @override
  void dispose() { 
    WidgetsBinding.instance.addObserver(this);
    super.dispose();
  }
  @override
  void didChangeAppLifecycleState(AppLifecycleState state){
    super.didChangeAppLifecycleState(state);
    switch (state) {
      case AppLifecycleState.paused:
        //App is running in the background
        break; 
      case AppLifecycleState.resumed:
        //App is being used again 
        break;
      case AppLifecycleState.inactive:
        //App is in foreground but inactive
        break;
      case AppLifecycleState.detached:
        //App view has been destroyed
        break;
    }
  }
class\u MyHomePageState使用WidgetsBindingObserver扩展状态{
@凌驾
void initState(){
super.initState();
WidgetsBinding.instance.addObserver(这个);
}
@凌驾
void dispose(){
WidgetsBinding.instance.addObserver(这个);
super.dispose();
}
@凌驾
void didchangeAppifecyclestate(AppLifecycleState状态){
super.didChangeAppLifecycleState(州);
开关(状态){
案例AppLifecycleState.paused:
//应用程序正在后台运行
打破
案例AppLifecycleState.resumed:
//应用程序正在重新使用
打破
案例AppLifecycleState.inactive:
//应用程序位于前台,但处于非活动状态
打破
案例AppLifecycleState.0:
//应用程序视图已被销毁
打破
}
}