Android setup issue
Hi! I am facing such issue: I use FCM for handling background messages and I try to init callkeep into my backgroundMessageHandler as it is described into example, but when I call _callKeep.setup i get
[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(E_ACTIVITY_DOES_NOT_EXIST, Activity doesn't exist, null, null) E/flutter (21173): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:581:7)
I added all necessary permissions into AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!-- These require runtime permissions on M -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
I also updated my activity: `import android.app.NotificationChannel import android.app.NotificationManager import android.content.Context import android.os.Build import io.flutter.app.FlutterApplication import io.flutter.plugin.common.PluginRegistry import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback import io.flutter.view.FlutterMain import com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin import com.github.cloudwebrtc.flutter_callkeep.FlutterCallkeepPlugin import io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingBackgroundService import io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin
class Application : FlutterApplication(), PluginRegistrantCallback { override fun onCreate() { super.onCreate() this.createChannel() FlutterFirebaseMessagingBackgroundService.setPluginRegistrant(this); FlutterMain.startInitialization(this) }
override fun registerWith(registry: PluginRegistry) {
FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebase.messaging.FirebaseMessagingPlugin"));
FlutterCallkeepPlugin.registerWith(registry?.registrarFor("com.github.cloudwebrtc.flutter_callkeep"));
FlutterLocalNotificationsPlugin.registerWith(registry!!.registrarFor("com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin"));
}
private fun createChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Create the NotificationChannel
val name = getString(R.string.default_notification_channel_id)
val channel = NotificationChannel(name, "default", NotificationManager.IMPORTANCE_HIGH)
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager
notificationManager?.createNotificationChannel(channel)
}
}
}`
I would great maybe to skip _checkPhoneAccountPermission, I just want to use it for displaying incoming call window when app is in background/locked or terminated.
BTW: when I use _callKeep.backToForeground() it works for Android 9, but doesn't for Android 11
Have you fixed this issue? I have the exact same problem.
Hi! No, I use https://pub.dev/packages/connectycube_flutter_call_kit
Same issue here ...
any solution yet?
I had the same issue. After some log-analysis I found out that in my case the phone account initialzation was done at a time where it couldn't do its job. Specifically the phone account check:
bool hasPhoneAccount = await callKeep.hasPhoneAccount();
if (!hasPhoneAccount) {
hasPhoneAccount = await callKeep.hasDefaultPhoneAccount(context, callSetup["android"]);
}
After putting it in the initialising of the first screen the user actually sees it worked for me.
@janhelwich How do you get the setting to stay I added the same code but it comes up on each app launch.
Hey @rlee1990 , honestly i think i didn't do anything more. It just does stay.