[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:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user