这是个用于测试cordova Ver3.0的插件编写的案例,可以返回android手机的运营商名称。
cordova plugin add https://github.com/gdmec/carrierplugin.git
- Android
- navigator.Carrier.getCarrierCode(onSuccess, onFailure);
<button onclick="test();">获取手机运营商</button>
<script type="text/javascript">
function test() {
Carrier.getCarrierCode(onSuccess, onFailure);
}
function onSuccess(result) {
alert("运营商: " + result);
}
function onFailure(err) {
alert("Failure: " + err);
}
</script>