[Android] Add cancel request method (#7)

* feat: add cancel connect for android

* fix: cancel connect only for android

* fix: clean up the project

* chore: new fvm version

* chore: code style and comments

* chore: bump version to 0.0.8
This commit is contained in:
Kseniia Nikitina
2024-05-18 12:34:05 +02:00
committed by GitHub
parent e4a8c2243f
commit 906e87c6a9
11 changed files with 72 additions and 7 deletions
@@ -203,6 +203,15 @@ class NearbyServiceManager(private var context: Context) {
}
fun cancelConnect(result: Result? = null) {
val actionListener = getActionListener(
result,
"Last connection request was cancelled",
"Failed to cancel the last connection process"
)
wifiManager.cancelConnect(wifiChannel, actionListener)
}
private fun addWifiActions() {
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION)
@@ -136,6 +136,14 @@ class NearbyServicePlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
}
}
"cancelConnect" -> {
try {
manager.cancelConnect(result)
} catch (e: Exception) {
onError(result, e)
}
}
else -> {
result.notImplemented()
}