MozMobileConnection.selectNetwork

  • Revision slug: Web/API/MozMobileConnection.selectNetwork
  • Revision title: MozMobileConnection.selectNetwork
  • Revision id: 403953
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment copyeditingMoved From DOM/MozMobileConnection.selectNetwork to Web/API/MozMobileConnection.selectNetwork

Revision Content

{{ non-standard_header() }}

{{ B2GOnlyHeader2('certified') }}

Summary

The selectNetwork method is used to manually select a network, overriding the radio's current selection.

Note: If the network is actually changed by this request, the voicechange and datachange events are fired.

Syntax

var request = navigator.mozMobileConnection.selectNetworks(network);

Parmeters

network
A {{domxref("MozMobileNetworkInfo")}} object representing the nework to select.

Return

A {{domxref("DOMRequest")}} object to handle the success or failure of the method call.

If the request fails, the request's error is one of:

  • RadioNotAvailable
  • RequestNotSupported
  • IllegalSIMorME
  • GenericFailure.

Example

var connection = navigator.mozMobileConnection;
var availableNetwork = connection.getNetworks();

availableNetwork.onsuccess = function () {
  var network = this.result[0];

  var switchNetwork = connection.selectNetwork(network);

  switchNetwork.onsuccess = function () {
    console.log('Successful switch to: ' + network.longName);
  }

  switchNetwork.onerror = function () {
    console.log('Unable to switch to: ' + network.longName);
  }
}

availableNetwork.onerror = function () {
  console.log('No network available: ' + this.error.name);
}

Specification

Not part of any specification.

See also

  • {{domxref("MozMobileConnection")}}
  • {{domxref("MozMobileNetworkInfo")}}
  • {{domxref("DOMRequest")}}

Revision Source

<p>{{ non-standard_header() }}</p>
<p>{{ B2GOnlyHeader2('certified') }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>selectNetwork</code> method is used to manually select a network, overriding the radio's current selection.</p>
<div class="note">
  <p><strong>Note:</strong> If the network is actually changed by this request, the <code>voicechange</code> and <code>datachange</code> events are fired.</p>
</div>
<h2 id="Syntax">Syntax</h2>
<pre>
var request = navigator.mozMobileConnection.selectNetworks(network);</pre>
<h3 id="Parmeters">Parmeters</h3>
<dl>
  <dt>
    <code>network</code></dt>
  <dd>
    A {{domxref("MozMobileNetworkInfo")}} object representing the nework to select.</dd>
</dl>
<h3 id="Return">Return</h3>
<p>A {{domxref("DOMRequest")}} object to handle the success or failure of the method call.</p>
<p>If the request fails, the request's <code>error</code> is one of:</p>
<ul>
  <li><code>RadioNotAvailable</code></li>
  <li><code>RequestNotSupported</code></li>
  <li><code>IllegalSIMorME</code></li>
  <li><code>GenericFailure</code>.</li>
</ul>
<h2 id="Example">Example</h2>
<pre class="brush: js">
var connection = navigator.mozMobileConnection;
var availableNetwork = connection.getNetworks();

availableNetwork.onsuccess = function () {
  var network = this.result[0];

  var switchNetwork = connection.selectNetwork(network);

  switchNetwork.onsuccess = function () {
    console.log('Successful switch to: ' + network.longName);
  }

  switchNetwork.onerror = function () {
    console.log('Unable to switch to: ' + network.longName);
  }
}

availableNetwork.onerror = function () {
  console.log('No network available: ' + this.error.name);
}
</pre>
<h2 id="Specification" name="Specification">Specification</h2>
<p>Not part of any specification.</p>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{domxref("MozMobileConnection")}}</li>
  <li>{{domxref("MozMobileNetworkInfo")}}</li>
  <li>{{domxref("DOMRequest")}}</li>
</ul>
Revert to this revision