PhoneGap-----Device Infomation、Network State and four kinds of Notifications
来源:互联网 发布:云帆大数据 百度网盘 编辑:程序博客网 时间:2024/05/15 04:00
The first , we can lead how to get the device Infomation ! It's very convenient by Phonegap ! At least , I think so !
<!DOCTYPE html><html ><head><title>My Device</title><script type="text/javascript" charset="utf-8" src="cordova.js"></script><script type="text/javascript" charset="utf-8"> function onLoad() { document.addEventListener("deviceready",onDeviceReady,false); } function onDeviceReady() { var myDiv = document.getElementById('props'); myDiv.innerHTML = 'Device Name: ' + device.name + '<br />' + 'Device PhoneGap:' + device.phonegap + '<br />' + 'Device Platform:' + device.platform + '<br />' + 'Device UUID: ' + device.uuid + '<br />' + 'Device Version: ' + device.version + '<br />' ; } </script></head><body onLoad="onLoad()"> <p id="props">Loading device properties...</p></body></html>
The second , we can check the network state :
<!DOCTYPE html><html ><head><title>Connectivity Example</title><script type="text/javascript" charset="utf-8" src="cordova.js"></script><script type="text/javascript" charset="utf-8"> document.addEventListener("deviceready",onDeviceReady,false); function onDeviceReady() { checkConnection(); } function checkConnection() { var networkState = navigator.network.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]); } </script></head><body> <p>A dialog box will report the network state.</p></body></html>
The third , the cases of four kinds of notifications :
<!DOCTYPE html><html><head><title>PhoneGap Event Example</title><script type="text/javascript" charset="utf-8" src="cordova.js"></script><script type="text/javascript" charset="utf-8"> function onLoad() { document.addEventListener("deviceready",onDeviceReady,false); } function onDeviceReady(){ } function showAlert(){ navigator.notification.alert( 'Game Over!',//message alertCallback,//callback 'Game Over', 'Done'//buttonName ); } function alertCallback(){ } function onConfirm(button){ alert('You selected button ' + button); } function showConfirm(){ navigator.notification.confirm( 'Game Over!', onConfirm, 'Game Over', 'Restart,Exit' ); } function playBeep(){ navigator.notification.beep(2); } function vibrate(){ navigator.notification.vibrate(4000); } </script></head><body onLoad="onLoad()"> <p><a href="#" onClick="showAlert();return false;">Show Alert</a></p> <p><a href="#" onClick="showConfirm();return false;">Show Confirmation</a></p> <p><a href="#" onClick="playBeep();return false;">Play Beep</a></p> <p><a href="#" onClick="vibrate();return false;">Vibrate</a></p></body></html>
- PhoneGap-----Device Infomation、Network State and four kinds of Notifications
- Four Kinds of Financial Aid
- 34) Four kinds of reference
- State and Notifications Broker
- State and Notifications Broker
- Spring in Action 3 -The four kinds of autowiring
- one example of network device
- 5 kinds of timers
- 4 kinds of references
- kinds of Containers
- BNU16494:Kinds of Fuwas
- all kinds of containers
- kinds of sort
- ZOJ2975 Kinds of Fuwas
- Kinds of Fuwas
- ZOJ2975-Kinds of Fuwas
- network device RXQ,TXQ, and related tuning
- Local Notifications and Push Notifications
- 单例模式
- gnu binutils
- win7开机后欢迎界面过后要等一段时间黑屏才进入界面这是怎么回事!
- 内部碎片 && 外部碎片
- Android系统开机画面修改
- PhoneGap-----Device Infomation、Network State and four kinds of Notifications
- 点击对话框外部取消对话框显示设置
- python+eclipse 开发环境配置
- Oracle URL helpfull
- Android Camera系列开发 (一): 通过Intent拍照
- vim显示中文乱码解决方法
- prim算法模版
- WINDOWS远程桌面的端口更改
- jQuery文档操作