This API provides interfaces and methods for users to set network bearer selection. Since Tizen 2.3, the "http://tizen.org/privilege/internet" privilege is additionally required.
If not declared in config.xml of wgt file, UnknownError occurs.
Since: 2.1
Interface | Method |
---|---|
NetworkBearerSelectionObject | |
NetworkBearerSelection | void requestRouteToHost (NetworkType networkType, DOMString domainName, NetworkSuccessCallback successCallback, optional ErrorCallback? errorCallback) void releaseRouteToHost (NetworkType networkType, DOMString domainName, SuccessCallback successCallback, optional ErrorCallback? errorCallback) |
NetworkSuccessCallback | void onsuccess () void ondisconnected () |
[NoInterfaceObject] interface NetworkBearerSelectionObject { readonly attribute NetworkBearerSelection networkbearerselection; };
Tizen implements NetworkBearerSelectionObject;
Since: 2.1
There is a tizen.networkbearerselection object that allows accessing the functionality of the Networkbearerselection API.
[NoInterfaceObject] interface NetworkBearerSelection { void requestRouteToHost(NetworkType networkType, DOMString domainName, NetworkSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void releaseRouteToHost(NetworkType networkType, DOMString domainName, SuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.1
This API offers methods for network bearer selection.
requestRouteToHost
void requestRouteToHost(NetworkType networkType, DOMString domainName, NetworkSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.1
The function must asynchronously acquire success or fail.
When called, it starts a request process defined with these set of steps:
The ErrorCallback method is launched with these error types:
Privilege level: partner
Privilege: http://tizen.org/privilege/networkbearerselection
Privilege level: public
Privilege: http://tizen.org/privilege/internet
Remark : The 'http://tizen.org/privilege/internet' privilege is required since Tizen 2.3.
Parameters:
Exceptions:
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
var statuscb = { onsuccess: function() { console.log("onsuccess func is called"); }, ondisconnected: function() { console.log("ondisconnected func is called"); } }; function ecb(e) { console.log("error callback is called : " + e.message + " : " + e.code); } tizen.networkbearerselection.requestRouteToHost("CELLULAR", "www.tizen.org", statuscb, ecb);
releaseRouteToHost
void releaseRouteToHost(NetworkType networkType, DOMString domainName, SuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.1
The function must asynchronously acquire success or fail.
When called, it closes a network connection.
The ErrorCallback method is launched with these error types:
Privilege level: partner
Privilege: http://tizen.org/privilege/networkbearerselection
Privilege level: public
Privilege: http://tizen.org/privilege/internet
Remark : The 'http://tizen.org/privilege/internet' privilege is required since Tizen 2.3.
Parameters:
Exceptions:
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
function scb() { console.log("success callback is called"); } function ecb(e) { console.log("error callback is called : " + e.message + " : " + e.code); } var statuscb = { onsuccess: function() { console.log("onsuccess func is called"); tizen.networkbearerselection.releaseRouteToHost("CELLULAR", "www.google.com", scb, ecb); }, ondisconnected: function() { console.log("ondisconnected func is called"); } }; tizen.networkbearerselection.requestRouteToHost("CELLULAR", "www.google.com", statuscb, ecb);
[Callback, NoInterfaceObject] interface NetworkSuccessCallback { void onsuccess(); void ondisconnected(); };
Since: 2.1
It is used in asynchronous operations with requestRouteToHost().
To guarantee that the NBS application runs on a device with telephony feature, declare the following feature requirements in the config file:
module NetworkBearerSelection { enum NetworkType { "CELLULAR", "UNKNOWN" }; [NoInterfaceObject] interface NetworkBearerSelectionObject { readonly attribute NetworkBearerSelection networkbearerselection; }; Tizen implements NetworkBearerSelectionObject; [NoInterfaceObject] interface NetworkBearerSelection { void requestRouteToHost(NetworkType networkType, DOMString domainName, NetworkSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void releaseRouteToHost(NetworkType networkType, DOMString domainName, SuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [Callback, NoInterfaceObject] interface NetworkSuccessCallback { void onsuccess(); void ondisconnected(); }; };