AndroidNotificationListener
AndroidNotificationListener copied to clipboard
flutter run issues
hi, i am using this plugin for my app, but throw a problem
e: D:\flutter\.pub-cache\hosted\pub.flutter-io.cn\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (73, 28): Type mismatch: inferred type is String? but TypeVariable(V) was expected
e: D:\flutter\.pub-cache\hosted\pub.flutter-io.cn\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (74, 31): Type mismatch: inferred type is String? but TypeVariable(V) was expected
e: D:\flutter\.pub-cache\hosted\pub.flutter-io.cn\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (75, 28): Type mismatch: inferred type is String? but TypeVariable(V) was expected
e: D:\flutter\.pub-cache\hosted\pub.flutter-io.cn\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (76, 29): Type mismatch: inferred type is String? but TypeVariable(V) was expected
this is your code:
internal inner class NotificationReceiver : BroadcastReceiver() {
val TAG = "NOTIFICATION_RECEIVER"
override fun onReceive(context: Context, intent: Intent) {
val packageName = intent.getStringExtra(NotificationListener.NOTIFICATION_PACKAGE_NAME)
val packageMessage = intent.getStringExtra(NotificationListener.NOTIFICATION_PACKAGE_MESSAGE)
val packageText = intent.getStringExtra(NotificationListener.NOTIFICATION_PACKAGE_TEXT)
val packageExtra = intent.getStringExtra(NotificationListener.NOTIFICATION_PACKAGE_EXTRA)
val map = HashMap<String, Any>()
map["packageName"] = packageName
map["packageMessage"] = packageMessage
map["packageText"] = packageText
map["packageExtra"] = packageExtra
eventSink?.success(map)
}
}
how to fix this, thanks !
Tell me , did you upgrade to the latest version of Android SDk and flutter ?. I suspect that it has to do with it.
However I am currently working on a project right now so I can't upgrade my environments yet I am sorry....
I will try to check that out though
yes, all upgrade to the latest version of Android SDk and flutter
Yeah I really suspect that it has to do with it . Once I do update everything on my side, I will try working on this package.. However it will take a long time because I am in the middle of an important project so updating now (because of numerous breaking changes) will cause lots of trouble to me....
However if you're on zoom we can have a video call... You fork the project and I will try to help you out
Sorry, I cannot make a video call with you. network restrictions in my place. I'm not in a hurry to use it. I can wait, You can work on your project first, and good luck to you~!
e: E:\development\flutter\.pub-cache\hosted\pub.dartlang.org\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (73, 7): Type inference failed: Cannot infer type parameter V in inline operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): Unit None of the following substitutions receiver: MutableMap<String, Any> arguments: (String,Any) receiver: MutableMap<String, String?> arguments: (String,String?) can be applied to receiver: kotlin.collections.HashMap<String, Any> /* = java.util.HashMap<String, Any> */ arguments: (String,String?)
having similar problem
Facing the same issue here
e: E:\development\flutter\.pub-cache\hosted\pub.dartlang.org\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (73, 7): Type inference failed: Cannot infer type parameter V in inline operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): Unit None of the following substitutions receiver: MutableMap<String, Any> arguments: (String,Any) receiver: MutableMap<String, String?> arguments: (String,String?) can be applied to receiver: kotlin.collections.HashMap<String, Any> /* = java.util.HashMap<String, Any> */ arguments: (String,String?)having similar problem
I have the same problem
e: E:\development\flutter\.pub-cache\hosted\pub.dartlang.org\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (73, 7): Type inference failed: Cannot infer type parameter V in inline operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): Unit None of the following substitutions receiver: MutableMap<String, Any> arguments: (String,Any) receiver: MutableMap<String, String?> arguments: (String,String?) can be applied to receiver: kotlin.collections.HashMap<String, Any> /* = java.util.HashMap<String, Any> */ arguments: (String,String?)having similar problemI have the same problem
I fixed this by changing the line from
https://github.com/PavieOlivier/AndroidNotificationListener/blob/8603f48e082c24d32d439e9f866c38339778cb28/android/src/main/kotlin/com/emilecode/android_notification_listener2/AndroidNotificationListener2Plugin.kt#L72
to
val map = mutableMapOf<String, String?>()
Which seems to have worked on Flutter 2.0.3