diff --git a/CrossPlatformModules.csproj b/CrossPlatformModules.csproj
index 7f9a72e2b..eee46e931 100644
--- a/CrossPlatformModules.csproj
+++ b/CrossPlatformModules.csproj
@@ -79,6 +79,10 @@
data-binding.xml
+
+
+ main-page.xml
+
main-page.xml
@@ -98,6 +102,9 @@
+
+ Designer
+
Designer
@@ -177,6 +184,7 @@
location-example.xml
+
@@ -298,8 +306,18 @@
webview.xml
+
+ connectivity.d.ts
+
+
+ connectivity.d.ts
+
+
+
+ connectivity.d.ts
+
file-name-resolver.d.ts
@@ -1693,6 +1711,12 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
@@ -1784,7 +1808,7 @@
False
-
+
\ No newline at end of file
diff --git a/apps/connectivity-demo/app.ts b/apps/connectivity-demo/app.ts
new file mode 100644
index 000000000..cb572300b
--- /dev/null
+++ b/apps/connectivity-demo/app.ts
@@ -0,0 +1,3 @@
+import application = require("application");
+application.mainModule = "main-page";
+application.start();
diff --git a/apps/connectivity-demo/main-page.ts b/apps/connectivity-demo/main-page.ts
new file mode 100644
index 000000000..2ee364995
--- /dev/null
+++ b/apps/connectivity-demo/main-page.ts
@@ -0,0 +1,16 @@
+import connectivity = require("connectivity");
+
+export function onGetConnectionType(args) {
+ var connectionType = connectivity.getConnectionType();
+ switch (connectionType) {
+ case connectivity.connectionType.none:
+ args.object.text = "No connection";
+ break;
+ case connectivity.connectionType.wifi:
+ args.object.text = "WiFi connection";
+ break;
+ case connectivity.connectionType.mobile:
+ args.object.text = "Mobile connection";
+ break;
+ }
+}
\ No newline at end of file
diff --git a/apps/connectivity-demo/main-page.xml b/apps/connectivity-demo/main-page.xml
new file mode 100644
index 000000000..c2695f1ee
--- /dev/null
+++ b/apps/connectivity-demo/main-page.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/apps/connectivity-demo/package.json b/apps/connectivity-demo/package.json
new file mode 100644
index 000000000..9d093acf8
--- /dev/null
+++ b/apps/connectivity-demo/package.json
@@ -0,0 +1,2 @@
+{ "name" : "connectivity-demo",
+ "main" : "app.js" }
\ No newline at end of file
diff --git a/apps/tests/connectivity-tests.ts b/apps/tests/connectivity-tests.ts
new file mode 100644
index 000000000..31227633c
--- /dev/null
+++ b/apps/tests/connectivity-tests.ts
@@ -0,0 +1,27 @@
+//
+// # Connectivity
+// Obtaining connectivity information requires the "connectivity" module.
+// ``` JavaScript
+import connectivity = require("connectivity");
+// ```
+//
+
+export var test_DummyTestForSnippetOnly0 = function () {
+ //
+ // ### Getting connection type
+ // ``` JavaScript
+ var connectionType = connectivity.getConnectionType();
+ switch (connectionType) {
+ case connectivity.connectionType.none:
+ ////console.log("No connection");
+ break;
+ case connectivity.connectionType.wifi:
+ ////console.log("WiFi connection");
+ break;
+ case connectivity.connectionType.mobile:
+ ////console.log("Mobile connection");
+ break;
+ }
+ // ```
+ //
+}
\ No newline at end of file
diff --git a/apps/tests/testRunner.ts b/apps/tests/testRunner.ts
index 63178d4f5..f9facf84a 100644
--- a/apps/tests/testRunner.ts
+++ b/apps/tests/testRunner.ts
@@ -76,6 +76,7 @@ allTests["HTML-VIEW"] = require("./ui/html-view/html-view-tests");
allTests["WEAK-EVENTS"] = require("./weak-event-listener-tests");
allTests["REPEATER"] = require("./ui/repeater/repeater-tests");
allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests');
+allTests["CONNECTIVITY"] = require("./connectivity-tests");
if (!isRunningOnEmulator()) {
allTests["LOCATION"] = require("./location-tests");
diff --git a/connectivity/connectivity-common.ts b/connectivity/connectivity-common.ts
new file mode 100644
index 000000000..0bff17c1c
--- /dev/null
+++ b/connectivity/connectivity-common.ts
@@ -0,0 +1,5 @@
+export module connectionType {
+ export var none = 0;
+ export var wifi = 1;
+ export var mobile = 2;
+}
\ No newline at end of file
diff --git a/connectivity/connectivity.android.ts b/connectivity/connectivity.android.ts
new file mode 100644
index 000000000..5acc2c43e
--- /dev/null
+++ b/connectivity/connectivity.android.ts
@@ -0,0 +1,31 @@
+import appModule = require("application");
+import common = require("connectivity/connectivity-common");
+
+declare var exports;
+require("utils/module-merge").merge(common, exports);
+
+var WIFI = "WIFI";
+var MOBILE = "MOBILE";
+
+function getActiveNetworkInfo(): android.net.NetworkInfo {
+ if (!appModule.android || !appModule.android.context) {
+ return null;
+ }
+
+ return appModule.android.context.getSystemService(android.content.Context.CONNECTIVITY_SERVICE).getActiveNetworkInfo();
+}
+
+export function getConnectionType(): number {
+ var activeNetworkInfo = getActiveNetworkInfo();
+ if (!activeNetworkInfo || !activeNetworkInfo.isConnected()) {
+ return common.connectionType.none;
+ }
+
+ var connectionType = activeNetworkInfo.getTypeName();
+ switch (connectionType) {
+ case WIFI:
+ return common.connectionType.wifi;
+ case MOBILE:
+ return common.connectionType.mobile;
+ }
+}
\ No newline at end of file
diff --git a/connectivity/connectivity.d.ts b/connectivity/connectivity.d.ts
new file mode 100644
index 000000000..595f9e7aa
--- /dev/null
+++ b/connectivity/connectivity.d.ts
@@ -0,0 +1,30 @@
+/**
+ * Contains connectivity utility methods.
+ */
+declare module "connectivity" {
+ /**
+ * Gets the type of connection.
+ * Returns a value from the connectivity.connectionType enumeration.
+ */
+ export function getConnectionType(): number;
+
+ /**
+ * Defines the different connection types.
+ */
+ export module connectionType {
+ /**
+ * Denotes no connection.
+ */
+ export var none: number;
+
+ /**
+ * Denotes a WiFi connection.
+ */
+ export var wifi: number;
+
+ /**
+ * Denotes a mobile connection, i.e. cellular network or WAN
+ */
+ export var mobile: number;
+ }
+}
\ No newline at end of file
diff --git a/connectivity/connectivity.ios.ts b/connectivity/connectivity.ios.ts
new file mode 100644
index 000000000..59a1dd385
--- /dev/null
+++ b/connectivity/connectivity.ios.ts
@@ -0,0 +1,54 @@
+import common = require("connectivity/connectivity-common");
+
+declare var exports;
+require("utils/module-merge").merge(common, exports);
+
+declare var sockaddr;
+
+function getNetworkReachability(host?: string): any {
+ if (host) {
+ return SCNetworkReachabilityCreateWithName(null, host);
+ }
+ else {
+ var zeroAddress = new interop.Reference(sockaddr, {
+ sa_len: 16,
+ sa_family: 2
+ });
+ return SCNetworkReachabilityCreateWithAddress(null, zeroAddress);
+ }
+}
+
+function getReachabilityFlags(host?: string): number {
+ var reachability = getNetworkReachability(host);
+ var flagsRef = new interop.Reference();
+ var gotFlags = SCNetworkReachabilityGetFlags(reachability, flagsRef);
+ CFRelease(reachability);
+ if (!gotFlags) {
+ return null;
+ }
+ return flagsRef.value;
+}
+
+function getConnectionTypeToHost(host?: string): number {
+ var flags = getReachabilityFlags(host);
+ if (!flags) {
+ return common.connectionType.none;
+ }
+
+ var isReachable = flags & kSCNetworkReachabilityFlagsReachable;
+ var connectionRequired = flags & kSCNetworkReachabilityFlagsConnectionRequired;
+ if (!isReachable || connectionRequired) {
+ return common.connectionType.none;
+ }
+
+ var isWWAN = flags & kSCNetworkReachabilityFlagsIsWWAN;
+ if (isWWAN) {
+ return common.connectionType.mobile;
+ }
+
+ return common.connectionType.wifi;
+}
+
+export function getConnectionType(): number {
+ return getConnectionTypeToHost();
+}
\ No newline at end of file
diff --git a/connectivity/package.json b/connectivity/package.json
new file mode 100644
index 000000000..2671ae61f
--- /dev/null
+++ b/connectivity/package.json
@@ -0,0 +1,2 @@
+{ "name" : "connectivity",
+ "main" : "connectivity.js" }
\ No newline at end of file