appcan学习开始之手机震动及停止

来源:互联网 发布:手机淘宝二维登录 编辑:程序博客网 时间:2024/06/01 20:48

前几天刚刚接触appcan,个人感觉这个平台很不错,平台大大降低了开发者的难度,先来写我学习的第一篇文章吧


手机震动与停止代码

html代码:

<div class="btn ub ub-ac bc-text-head ub-pc bc-btn umar-t1"  id="btn1">
    手机震动
</div>
<div class="btn ub ub-ac bc-text-head ub-pc bc-btn umar-t"  id="btn2">
    震动停止
</div>


js代码:

appcan.button("#btn1", "ani-act", function() {
            appcan.device.vibrate(5000);//震动5秒
})
appcan.button("#btn2", "ani-act", function() {
            appcan.device.cancelVibrate();//手动停止
})



获取设备信息代码


html:

<div class="btn ub ub-ac bc-text-head ub-pc bc-btn umar-t"  id="btn3">
    获取设备信息
</div>


js:

appcan.button("#btn3", "ani-act", function() {
            appcan.device.getInfo(1, function(err,data,dataType,optId) {
              if(err){
                  alert('err');
                  return;
              }else{
                  alert(data);
              }
            });
})


红色字体参数代表要获取的手机信息:

1:代表获取手机当前版本,如:android4.1.1

2:代表获取手机的品牌  如sumsung,huawei

3:键盘

4:蓝牙

5:wifi

6:相机

7:GPS

8:GPRS 无线分组业务

9:touch  触屏

10:手机imei

11:deviceToken

13:connectStatus

14:restDiskSize

15:mobileOperatorName 网络运营商

16:macAddress 当前设备的 WIFI mac 地址

17:model  硬件型号

0 0