TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Check Network Connection with PhoneGap using Android
Bhushan Singh
Feb 09
2015
Code
2.9
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
check_newtwork_conne
<script type=
"text/javascript"
charset=
"utf-8"
>
// Wait for PhoneGap to load
//
document.addEventListener(
"deviceready"
, onDeviceReady,
false
);
// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function
onDeviceReady() {
check_my_Connection();
}
function
check_my_Connection() {
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>
Check network connection with phonegap using android