순서가 좀 꼬였습니다. 내부 API 적용은 쉬워보여서 넘어갔는데... 자꾸 실행이 안되길래... 정리 한번 해봤습니다~ ㅎㅎ
폽갭 3.0으로 넘어 오면서 node.js 라는 툴(?)로 소스를 관리하고 있습니다.
node.js검색해서 설치한후~
npm 명령으로 아래 3가지를 우선 설치해 줍니다~
c:\npm install -g cordoba
c:\npm install -g phonegap
c:\npm install -g plugman
기본적인 hello world 프로젝트를 만듭니다.
C:\>cordova create hello com.example.hello "HelloWorld"
C:\>cd hello
C:\hello>cordova platform add android
그 다음 이클립스에서 Android Project from Existing Code 불러오기~
에뮬실행하면 hello world 가 나옵니다~
assets\www 폴더에서
index.html, cordova.js, cordova_plugins.js파일과 plugins 폴더만 남겨두고 모두 삭제해 버립니다. (필요없으니깐요~)
여기까지가 기본적인 절차입니다~ ㅠ.ㅠ
코르도바 명령으로 플러그인 설치시작~
C:\hello>cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration.git
C:\hello>cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
assets\www\index.html 파일의 내용을 모두 지우고, 아래 예제 실행~
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Notification Example</title> <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <script type="text/javascript" charset="utf-8"> // Wait for device API libraries to load // document.addEventListener("deviceready", onDeviceReady, false); // device APIs are available // function onDeviceReady() { // Empty } // alert dialog dismissed function alertDismissed() { // do something } // Show a custom alertDismissed // function showAlert() { navigator.notification.alert( 'You are the winner!', // message alertDismissed, // callback 'Game Over', // title 'Done' // buttonName ); } </script> </head> <body> <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p> </body> </html>
에뮬 실행후~ Show Alert 실행하면~ 다이얼로그 경고 문구가 화면에 뜨면~ 완성~
file;///android_asset/cordova.js 라는 오류가 ..뜨는데 무슨 오류..일가요