自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

PhoneGap API幫助文檔翻譯Notification提醒

移動開發(fā)
PhoneGap API幫助文檔翻譯Notification提醒是本文要介紹的內(nèi)容,主要是來了解PhoneGap API文檔的內(nèi)容,具體PhoneGap API文檔內(nèi)容的詳解來看本文。

PhoneGap API幫助文檔翻譯Notification提醒是本文要介紹的內(nèi)容,主要是來了解PhoneGap API文檔的內(nèi)容,具體PhoneGap API文檔內(nèi)容的詳解來看本文,設(shè)備的視覺、聽覺和觸覺通知。

方法:

  1. notification.alert  
  2. notification.confirm  
  3. notification.beep  
  4. notification.vibrate  
  5. notification.alert  

顯示一個定制的警告或?qū)υ捒颉?/p>

  1. navigator.notification.alert(message, alertCallback, [title], [buttonName]);    
  2. navigator.notification.alert(message, alertCallback, [title], [buttonName]); 

message:對話框信息。(字符串類型)

alertCallback:當(dāng)警告對話框被忽略時調(diào)用的回調(diào)函數(shù)。(函數(shù)類型)

title:對話框標(biāo)題。(字符串類型)(可選項,默認值為“Alert”)

buttonName:按鈕名稱(字符串類型)(可選項,默認值為“OK”)

說明:

大多數(shù)PhoneGap使用本地對話框?qū)崿F(xiàn)該功能。然而,一些平臺只是簡單的使用瀏覽器的alert函數(shù),而這種方法通常是不能定制的。

支持的平臺:

Android

BlackBerry (OS 4.6)

BlackBerry WebWorks (OS 5.0或更高版本)

iPhone

簡單的范例:

  1. // Android / BlackBerry WebWorks (OS 5.0 and higher) // iPhone    
  2. function alertDismissed() {    
  3.     // 進行處理    
  4. }    
  5.     
  6. navigator.notification.alert(    
  7.     'You are the winner!',  // 顯示信息    
  8.     alertDismissed,         // 警告被忽視的回調(diào)函數(shù)    
  9.     'Game Over',            // 標(biāo)題    
  10.     'Done'                  // 按鈕名稱    
  11. );    
  12.     
  13. // BlackBerry (OS 4.6) // webOS    
  14. navigator.notification.alert('You are the winner!');    
  15. // Android / BlackBerry WebWorks (OS 5.0 and higher) // iPhone  
  16. function alertDismissed() {  
  17.  // 進行處理  
  18. }  
  19.  
  20. navigator.notification.alert(  
  21.  'You are the winner!',  // 顯示信息  
  22.     alertDismissed,         // 警告被忽視的回調(diào)函數(shù)  
  23.     'Game Over',            // 標(biāo)題  
  24.     'Done'                  // 按鈕名稱  
  25. );  
  26.  
  27. // BlackBerry (OS 4.6) // webOS  
  28. navigator.notification.alert('You are the winner!');  
  29. 完整的范例:  
  30. view plaincopy to clipboardprint?<!DOCTYPE html>    
  31. <html>    
  32. <head>        
  33. <title>Notification Example</title>    
  34.     
  35. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>    
  36. <script type="text/javascript" charset="utf-8">    
  37.     
  38.     // 等待加載PhoneGap    
  39.     document.addEventListener("deviceready", onDeviceReady, false);     
  40.         
  41.     // PhoneGap加載完畢    
  42.     function onDeviceReady() {    
  43.         // 空    
  44.     }    
  45.         
  46.     // 警告對話框被忽視    
  47.     function alertDismissed() {    
  48.         // 進行處理    
  49.     }    
  50.         
  51.     // 顯示一個定制的警告框    
  52.     function showAlert() {    
  53.         navigator.notification.alert(    
  54.             'You are the winner!',  // 顯示信息    
  55.             alertDismissed,         // 警告被忽視的回調(diào)函數(shù)    
  56.             'Game Over',            // 標(biāo)題    
  57.             'Done'                  // 按鈕名稱    
  58.         );    
  59.     }    
  60.     
  61. </script>    
  62. </head>    
  63. <body>    
  64.     <p><a href="#" onclick="showConfirm(); return false;">Show Confirm</a></p>    
  65. </body>    
  66. </html>    
  67. <!DOCTYPE html> 
  68. <html> 
  69. <head>   
  70. <title>Notification Example</title> 
  71.  
  72. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> 
  73. <script type="text/javascript" charset="utf-8"> 
  74.  
  75.  // 等待加載PhoneGap  
  76.  document.addEventListener("deviceready", onDeviceReady, false);   
  77.    
  78.  // PhoneGap加載完畢  
  79.  function onDeviceReady() {  
  80.   // 空  
  81.  }  
  82.    
  83.  // 警告對話框被忽視  
  84.  function alertDismissed() {  
  85.   // 進行處理  
  86.  }  
  87.    
  88.  // 顯示一個定制的警告框  
  89.  function showAlert() {  
  90.   navigator.notification.alert(  
  91.    'You are the winner!',  // 顯示信息  
  92.    alertDismissed,         // 警告被忽視的回調(diào)函數(shù)  
  93.    'Game Over',            // 標(biāo)題  
  94.    'Done'                  // 按鈕名稱  
  95.   );  
  96.  }  
  97.  
  98. </script> 
  99. </head> 
  100. <body> 
  101.  <p><a href="#" onclick="showConfirm(); return false;">Show Confirm</a></p> 
  102. </body> 
  103. </html> 
  104. notification.confirm   

顯示一個可定制的確認對話框。

  1. navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels]);    
  2. navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels]); 

message:對話框信息。(字符串類型)

confirmCallback:按下按鈕后觸發(fā)的回調(diào)函數(shù),返回按下按鈕的索引(1、2或3)。(函數(shù)類型)

title:對話框標(biāo)題。(字符串類型)(可選項,默認值為“Confirm”)

buttonLabels:逗號分隔的按鈕標(biāo)簽字符串。(字符串類型)(可選項,默認值為“OK、Cancel”)

#p#

PhoneGap API說明:

notification.confirm函數(shù)顯示一個定制性比瀏覽器的confirm函數(shù)更好的本地對話框。

支持的平臺:

Android

BlackBerry WebWorks (OS 5.0或更高版本)

iPhone

簡單的范例:

  1. // 處理確認對話框返回的結(jié)果    
  2. function onConfirm(button) {    
  3.     alert('You selected button ' + button);    
  4. }    
  5.     
  6. // 顯示一個定制的確認對話框    
  7. function showConfirm() {    
  8.     navigator.notification.confirm(    
  9.         'You are the winner!',  // 顯示信息    
  10.         onConfirm,              // 按下按鈕后觸發(fā)的回調(diào)函數(shù),返回按下按鈕的索引    
  11.         'Game Over',            // 標(biāo)題    
  12.         'Restart,Exit'          // 按鈕標(biāo)簽    
  13.     );    
  14.  }    
  15. // 處理確認對話框返回的結(jié)果  
  16. function onConfirm(button) {  
  17.  alert('You selected button ' + button);  
  18. }  
  19.  
  20. // 顯示一個定制的確認對話框  
  21. function showConfirm() {  
  22.     navigator.notification.confirm(  
  23.      'You are the winner!',  // 顯示信息  
  24.      onConfirm,              // 按下按鈕后觸發(fā)的回調(diào)函數(shù),返回按下按鈕的索引  
  25.      'Game Over',            // 標(biāo)題  
  26.      'Restart,Exit'          // 按鈕標(biāo)簽  
  27.     );  
  28.  } 

完整的范例:

  1. <!DOCTYPE html>    
  2. <html>    
  3. <head>        
  4. <title>Notification Example</title>    
  5.     
  6. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>    
  7. <script type="text/javascript" charset="utf-8">    
  8.         
  9.     // 等待加載PhoneGap    
  10.     document.addEventListener("deviceready", onDeviceReady, false);     
  11.         
  12.     // PhoneGap加載完畢    
  13.     function onDeviceReady() {    
  14.         // 空    
  15.     }    
  16.         
  17.     // 處理確認對話框返回的結(jié)果    
  18.     function onConfirm(button) {    
  19.         alert('You selected button ' + button);    
  20.     }    
  21.         
  22.     // 顯示一個定制的確認對話框    
  23.     function showConfirm() {    
  24.         navigator.notification.confirm(    
  25.             'You are the winner!',  // 顯示信息    
  26.             onConfirm,              // 按下按鈕后觸發(fā)的回調(diào)函數(shù),返回按下按鈕的索引       
  27.             'Game Over',            // 標(biāo)題    
  28.             'Restart,Exit'          // 按鈕標(biāo)簽    
  29.         );    
  30.     }    
  31.     
  32. </script>    
  33. </head>    
  34. <body>    
  35.     <p><a href="#" onclick="showConfirm(); return false;">Show Confirm</a></p>    
  36. </body>    
  37. </html>    
  38. <!DOCTYPE html> 
  39. <html> 
  40. <head>   
  41. <title>Notification Example</title> 
  42.  
  43. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> 
  44. <script type="text/javascript" charset="utf-8"> 
  45.    
  46.  // 等待加載PhoneGap  
  47.  document.addEventListener("deviceready", onDeviceReady, false);   
  48.    
  49.  // PhoneGap加載完畢  
  50.  function onDeviceReady() {  
  51.   // 空  
  52.  }  
  53.    
  54.  // 處理確認對話框返回的結(jié)果  
  55.  function onConfirm(button) {  
  56.   alert('You selected button ' + button);  
  57.  }  
  58.    
  59.  // 顯示一個定制的確認對話框  
  60.  function showConfirm() {  
  61.   navigator.notification.confirm(  
  62.    'You are the winner!',  // 顯示信息  
  63.    onConfirm,              // 按下按鈕后觸發(fā)的回調(diào)函數(shù),返回按下按鈕的索引   
  64.    'Game Over',            // 標(biāo)題  
  65.    'Restart,Exit'          // 按鈕標(biāo)簽  
  66.   );  
  67.  }  
  68.  
  69. </script> 
  70. </head> 
  71. <body> 
  72.  <p><a href="#" onclick="showConfirm(); return false;">Show Confirm</a></p> 
  73. </body> 
  74. </html> 
  75. notification.beep   

設(shè)備將發(fā)出蜂鳴聲。

  1. navigator.notification.beep(times);    
  2. navigator.notification.beep(times); 

times:蜂鳴聲的重復(fù)次數(shù)。(數(shù)字類型)

支持的平臺:

Android

BlackBerry (OS 4.6)

BlackBerry WebWorks (OS 5.0或更高版本)

iPhone

簡單的范例:

  1. // 蜂鳴2次!    
  2. navigator.notification.beep(2);    
  3. // 蜂鳴2次!  
  4. navigator.notification.beep(2); 

完整的范例:

  1. <!DOCTYPE html>    
  2. <html>    
  3. <head>        
  4. <title>Notification Example</title>    
  5.     
  6. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>    
  7. <script type="text/javascript" charset="utf-8">    
  8.     
  9. // 等待加載PhoneGap    
  10. document.addEventListener("deviceready", onDeviceReady, false);     
  11.     
  12. // PhoneGap加載完畢    
  13. function onDeviceReady() {    
  14.     // 空    
  15. }    
  16.     
  17. // 顯示一個定制的警告框    
  18. function showAlert() {    
  19.     navigator.notification.alert(    
  20.         'You are the winner!',  // 顯示信息    
  21.         'Game Over',            // 標(biāo)題    
  22.         'Done'                  // 按鈕名稱    
  23.     );    
  24. }    
  25.     
  26. // 蜂鳴三次    
  27. function playBeep() {    
  28.     navigator.notification.beep(3);    
  29. }    
  30.     
  31. // 震動兩秒    
  32. function vibrate() {    
  33.     navigator.notification.vibrate(2000);    
  34. }    
  35.     
  36. </script>    
  37. </head>    
  38. <body>    
  39.     <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>    
  40.     <p><a href="#" onclick="playBeep(); return false;">Play Beep</a></p>    
  41.     <p><a href="#" onclick="vibrate(); return false;">Vibrate</a></p>    
  42. </body>    
  43. </html>    
  44. <!DOCTYPE html> 
  45. <html> 
  46. <head>   
  47. <title>Notification Example</title> 
  48.  
  49. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> 
  50. <script type="text/javascript" charset="utf-8"> 
  51.  
  52. // 等待加載PhoneGap  
  53. document.addEventListener("deviceready", onDeviceReady, false);   
  54.  
  55. // PhoneGap加載完畢  
  56. function onDeviceReady() {  
  57.     // 空  
  58. }  
  59.  
  60. // 顯示一個定制的警告框  
  61. function showAlert() {  
  62.     navigator.notification.alert(  
  63.      'You are the winner!',  // 顯示信息  
  64.      'Game Over',            // 標(biāo)題  
  65.      'Done'                  // 按鈕名稱  
  66.     );  
  67. }  
  68.  
  69. // 蜂鳴三次  
  70. function playBeep() {  
  71.     navigator.notification.beep(3);  
  72. }  
  73.  
  74. // 震動兩秒  
  75. function vibrate() {  
  76.     navigator.notification.vibrate(2000);  
  77. }  
  78.  
  79. </script> 
  80. </head> 
  81. <body> 
  82.  <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p> 
  83.  <p><a href="#" onclick="playBeep(); return false;">Play Beep</a></p> 
  84.  <p><a href="#" onclick="vibrate(); return false;">Vibrate</a></p> 
  85. </body> 
  86. </html> 

#p#

Android的特異情況:

Androids會播放在“設(shè)置/音效及顯示”面板中指定的默認“通知鈴聲”。

iPhone的特異情況:

忽略蜂鳴次數(shù)參數(shù)。

iPhone沒有本地的蜂鳴API。

PhoneGap通過多媒體API播放音頻文件來實現(xiàn)蜂鳴。

用戶必須提供一個包含所需的蜂鳴聲的文件。

此文件播放時長必須短于30秒,位于www/root,并且必須命名為beep.wav。

notification.vibrate  
 
使設(shè)備震動指定的時長。

  1. navigator.notification.vibrate(milliseconds);    
  2. navigator.notification.vibrate(milliseconds); 

time:以毫秒為單位的設(shè)備震動時長,1000毫秒為1秒。(數(shù)字類型)

支持的平臺:

Android

BlackBerry (OS 4.6)

BlackBerry WebWorks (OS 5.0或更高版本)

iPhone

簡單的范例:

  1. // 震動2.5秒    
  2. navigator.notification.vibrate(2500);    
  3. // 震動2.5秒  
  4. navigator.notification.vibrate(2500); 

完整的范例:

  1. <!DOCTYPE html>    
  2. <html>    
  3. <head>        
  4. <title>Notification Example</title>    
  5.     
  6. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>    
  7. <script type="text/javascript" charset="utf-8">    
  8.     
  9. // 等待加載PhoneGap    
  10. document.addEventListener("deviceready", onDeviceReady, false);     
  11.     
  12. // PhoneGap加載完畢    
  13. function onDeviceReady() {    
  14.     //空    
  15. }    
  16.     
  17. // 顯示定制警告框    
  18. function showAlert() {    
  19.     navigator.notification.alert(    
  20.         'You are the winner!',  // 顯示信息    
  21.         'Game Over',            // 標(biāo)題    
  22.         'Done'                  // 按鈕名稱    
  23.     );    
  24. }    
  25.     
  26. // 響三次    
  27. function playBeep() {    
  28.     navigator.notification.beep(3);    
  29. }    
  30.     
  31. // 震動兩秒    
  32. function vibrate() {    
  33.     navigator.notification.vibrate(2000);    
  34. }    
  35.     
  36. </script>    
  37. </head>    
  38. <body>    
  39.     <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>    
  40.     <p><a href="#" onclick="playBeep(); return false;">Play Beep</a></p>    
  41.     <p><a href="#" onclick="vibrate(); return false;">Vibrate</a></p>    
  42. </body>    
  43. </html>    
  44. <!DOCTYPE html> 
  45. <html> 
  46. <head>   
  47. <title>Notification Example</title> 
  48.  
  49. <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> 
  50. <script type="text/javascript" charset="utf-8"> 
  51.  
  52. // 等待加載PhoneGap  
  53. document.addEventListener("deviceready", onDeviceReady, false);   
  54.  
  55. // PhoneGap加載完畢  
  56. function onDeviceReady() {  
  57.     //空  
  58. }  
  59.  
  60. // 顯示定制警告框  
  61. function showAlert() {  
  62.     navigator.notification.alert(  
  63.      'You are the winner!',  // 顯示信息  
  64.      'Game Over',            // 標(biāo)題  
  65.      'Done'                  // 按鈕名稱  
  66.     );  
  67. }  
  68.  
  69. // 響三次  
  70. function playBeep() {  
  71.     navigator.notification.beep(3);  
  72. }  
  73.  
  74. // 震動兩秒  
  75. function vibrate() {  
  76.     navigator.notification.vibrate(2000);  
  77. }  
  78.  
  79. </script> 
  80. </head> 
  81. <body> 
  82.  <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p> 
  83.  <p><a href="#" onclick="playBeep(); return false;">Play Beep</a></p> 
  84.  <p><a href="#" onclick="vibrate(); return false;">Vibrate</a></p> 
  85. </body> 
  86. </html> 

iPhone的特異情況:

time:忽略時長參數(shù),震動時長為預(yù)先設(shè)定值。

簡單的范例:

  1. <span style="font-size:13px;">navigator.notification.vibrate();    
  2. navigator.notification.vibrate(2500);   // 2500被忽略掉</span>   

小結(jié):PhoneGap API幫助文檔翻譯Notification提醒的內(nèi)容介紹完了,希望通過:PhoneGap API文檔內(nèi)容的學(xué)習(xí)能對你有所幫助!

責(zé)任編輯:zhaolei 來源: 網(wǎng)絡(luò)轉(zhuǎn)載
相關(guān)推薦

2011-09-13 14:40:16

PhoneGap AP

2011-09-13 16:08:58

PhoneGap AP

2011-09-13 10:17:26

PhoneGap AP

2011-09-13 11:06:08

PhoneGap AP

2011-09-13 10:40:25

PhoneGap AP

2011-09-13 14:07:45

PhoneGap AP

2011-09-13 15:51:11

PhoneGap AP

2011-09-13 16:24:11

PhoneGap AP

2011-12-22 10:33:39

PhoneGap APNotificatio

2011-09-13 13:17:27

PhoneGap AP

2011-10-11 09:50:44

PhoneGap常見問題

2011-10-11 09:03:57

常見問題PhoneGap

2009-07-26 20:36:07

EclipseJDKAPI幫助文檔

2011-12-20 11:20:46

PhoneGap APCompass

2011-12-19 16:09:32

PhoneGap APCamera

2011-12-19 15:30:25

AccelerometPhoneGap AP

2011-12-20 15:34:55

PhoneGap APConnection

2011-12-20 17:15:52

PhoneGap APEvents

2011-12-22 10:45:32

PhoneGap APStorage

2011-12-21 21:56:45

PhoneGap APFile
點贊
收藏

51CTO技術(shù)棧公眾號