also looking at this
feat(android): getNetworkStatus — the action iOS cannot serve
#146
7 files
+407
-3
| @@ -63,6 +63,7 @@ object CraftNative { | ||
| 63 | 63 | private external fun nativeClipboardWrite(activity: Activity, text: String): Boolean |
| 64 | 64 | private external fun nativeOpenUrl(activity: Activity, url: String): Boolean |
| 65 | 65 | private external fun nativeShare(activity: Activity, text: String, title: String): Boolean |
| 66 | private external fun nativeGetNetworkStatus(activity: Activity): String? | |
| 66 | 67 | |
| 67 | 68 | /** |
| 68 | 69 | * `getDeviceInfo`, or null to use the Kotlin implementation. |
| @@ -165,4 +166,14 @@ object CraftNative { | ||
| 165 | 166 | false |
| 166 | 167 | } |
| 167 | 168 | } |
| 169 | ||
| 170 | /** The active network as JSON, or null to use the Kotlin implementation. */ | |
| 171 | fun getNetworkStatus(activity: Activity): String? { | |
| 172 | if (!isAvailable) return null | |
| 173 | return try { | |
| 174 | nativeGetNetworkStatus(activity) | |
| 175 | } catch (e: UnsatisfiedLinkError) { | |
| 176 | null | |
| 177 | } | |
| 178 | } | |
| 168 | 179 | } |