N/A
N/A
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<feature name="NetworkStatus"> <param name="ios-package" value="CDVConnection"/> </feature>
function checkConnection() { var networkState = navigator.connection.type; var states = {}; states[Connection.UNKNOWN] = 'Unknown connection'; states[Connection.ETHERNET] = 'Ethernet connection'; states[Connection.WIFI] = 'WiFi connection'; states[Connection.CELL_2G] = 'Cell 2G connection'; states[Connection.CELL_3G] = 'Cell 3G connection'; states[Connection.CELL_4G] = 'Cell 4G connection'; states[Connection.NONE] = 'No network connection'; alert('Connection type: ' + states[networkState]); } checkConnection();
유형 | 네트워크 상태 |
---|---|
Connection.UNKNOWN | 알 수 없는 네트워크 상태. |
Connection.ETHERNET | 이더넷 |
Connection.WIFI | Wi-Fi |
Connection.CELL_2G | 2G |
Connection.CELL_3G | 3G |
Connection.CELL_4G | 4G |
Connection.NONE | 네트워크를 지원하지 않음. |