Skip to content

Unable to answer call in background service for android ? #540

Open
@harryandroiddev

Description

@harryandroiddev

Describe the bug
Unable to accept the incoming call in background service in android os .

To Reproduce
Steps to reproduce the behavior:

  1. Start background service
  2. register sip user and close the app
  3. handle sip listeners and on incoming call accept the call .

The method to answer the call throws error
mediaStream = await navigator.mediaDevices.getUserMedia(
mediaConstraints,
); // getting error at this line of code
call?.answer(
helper!.buildCallOptions(true),
mediaStream: mediaStream,
);

Error Logs

E/MethodChannel#FlutterWebRTC.Method(23398): Failed to handle method call
E/MethodChannel#FlutterWebRTC.Method(23398): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Intent android.app.Activity.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)' on a null object reference
E/MethodChannel#FlutterWebRTC.Method(23398): at com.cloudwebrtc.webrtc.video.camera.DeviceOrientationManager.start(DeviceOrientationManager.java:57)
E/MethodChannel#FlutterWebRTC.Method(23398): at com.cloudwebrtc.webrtc.video.camera.CameraUtils.(CameraUtils.java:48)
E/MethodChannel#FlutterWebRTC.Method(23398): at com.cloudwebrtc.webrtc.MethodCallHandlerImpl.initialize(MethodCallHandlerImpl.java:176)
E/MethodChannel#FlutterWebRTC.Method(23398): at com.cloudwebrtc.webrtc.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:345)
E/MethodChannel#FlutterWebRTC.Method(23398): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
E/MethodChannel#FlutterWebRTC.Method(23398): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
E/MethodChannel#FlutterWebRTC.Method(23398): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#FlutterWebRTC.Method(23398): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
E/MethodChannel#FlutterWebRTC.Method(23398): at android.os.Handler.handleCallback(Handler.java:958)
E/MethodChannel#FlutterWebRTC.Method(23398): at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#FlutterWebRTC.Method(23398): at android.os.Looper.loopOnce(Looper.java:230)
E/MethodChannel#FlutterWebRTC.Method(23398): at android.os.Looper.loop(Looper.java:319)
E/MethodChannel#FlutterWebRTC.Method(23398): at android.app.ActivityThread.main(ActivityThread.java:8893)
E/MethodChannel#FlutterWebRTC.Method(23398): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#FlutterWebRTC.Method(23398): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
E/MethodChannel#FlutterWebRTC.Method(23398): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
E/flutter (23398): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: Unable to getUserMedia: Attempt to invoke virtual method 'android.content.Intent android.app.Activity.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)' on a null object reference
E/flutter (23398): #0 MediaDeviceNative.getUserMedia (package:flutter_webrtc/src/native/mediadevices_impl.dart:48:7)

Expected behavior
Answer the call in background

System Infomation()
[✓] Flutter (Channel stable, 3.29.2, on macOS 15.3.1 24D70 darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc4)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.3)
[✓] VS Code (version 1.98.2)
[✓] Connected device (5 available)
[✓] Network resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions