Skip to Main Content
建構Android應用程式--使用HTML、CSS和JavaScript 第二版
book

建構Android應用程式--使用HTML、CSS和JavaScript 第二版

by Jonathan Stark, Brian Jepson
May 2012
Intermediate to advanced content levelIntermediate to advanced
176 pages
3h 43m
Chinese
GoTop Information, Inc.
Content preview from 建構Android應用程式--使用HTML、CSS和JavaScript 第二版
132
第七章
JavaScript
控制手機
現在,舞台已設置好,我們可以呼叫本機設備功能,強化應用程式了。多虧
phonegap.js
如果你想讓手機震動
200
毫秒,所須做的就是加一點
JavaScript
到你的程式碼之中:
navigator.notification.vibrate(200);
很簡單,對吧?
嗶嗶聲、震動以及警示
PhoneGap
讓嗶嗶聲、震動以及警示功能變得很簡單,所以,我要把他們整合成一個範例。
明確的講,當使用者建立一個項目,把他的資料放入,如果超出每日卡路里限額時,就讓
程式發出嗶嗶聲、震動以及顯示特定的警示訊息。為此,把下列函式加入
kilo.js
的尾端(請
注意
,
要修改的是在
Eclipse
專案裡的
kilo.js
,而不是在前面章節提到的原始那份):
function checkBudget() {
var currentDate = sessionStorage.currentDate;
var dailyBudget = localStorage.budget;
db.transaction(
function(transaction) {
transaction.executeSql(
'SELECT SUM(calories) AS currentTotal FROM entries WHERE date = ?;',
[currentDate],
function (transaction, result) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

大模型应用开发极简入门 : 基于GPT-4和ChatGPT

大模型应用开发极简入门 : 基于GPT-4和ChatGPT

Olivier Caelen, Marie-Alice Blete
HBase管理指南

HBase管理指南

Posts & Telecom Press, Yifeng Jiang
自然语言处理与计算语言学

自然语言处理与计算语言学

Posts & Telecom Press, Bhargav Srinivasa-Desikan

Publisher Resources

ISBN: 9789862764817