Skip to main content
조회 수 4219 추천 수 1 댓글 3
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

순서가 좀 꼬였습니다. 내부 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 실행하면~ 다이얼로그 경고 문구가 화면에 뜨면~ 완성~



  • ?
    최성일 2014.12.03 13:59
    예제를 만들고 실행 해보고있는데 Uncaught Reference Error : require is not defined source :
    file;///android_asset/cordova.js 라는 오류가 ..뜨는데 무슨 오류..일가요
  • profile
    geusgod 2014.12.09 09:30
    에고... 댓글이 메일로 안날라와서 이제서야 봤습니다. -0-;
    Hello World는 뜨셨나요? 작성시점이 작년이라... 폰갭 버젼도 알려주셔야 확인해 볼수 있을것 같은데요~
  • ?
    최성일 2014.12.09 17:28
    답변 감사합니다. www폴더를 못찾아서 기존에 대놓고 보이는 www폴더로 index파일을 만들어서 그렇게 됬었습니다. 문제 해결 후 notification alert를 2.9에서 3.64버전으로 업데이트 한 후에 만들면 notificaiton을 정의 할 수 없다고 에러가 나옵니다. 전에는 잘 되는데 3.0 이상으로 업뎃한 후에.. 말썽인게 너무나 많네요 도움 주시면 감사하겠습니다.