hybrid mobile app - Cordova not detecting official plugins -
hybrid mobile app - Cordova not detecting official plugins -
i struggling cordova not detecting plugin.
here exact steps following:
~/desktop → cordova -v 3.5.0-0.2.4 ~/desktop → cordova create test com.example.test justatest creating new cordova project name "justatest" , id "com.example.test" @ location "/users/adam/desktop/test" ~/desktop → cd test ~/desktop/test → cordova platform add together android creating android project... creating cordova project android platform: path: platforms/android package: com.example.test name: justatest android target: android-19 copying template files... running: android update project --subprojects --path "platforms/android" --target android-19 --library "cordovalib" resolved location of library project to: /users/adam/desktop/test/platforms/android/cordovalib updated , renamed default.properties project.properties updated local.properties no project name specified, using activity name 'justatest'. if wish alter it, edit first line of build.xml. added file platforms/android/build.xml added file platforms/android/proguard-project.txt updated project.properties updated local.properties no project name specified, using project folder name 'cordovalib'. if wish alter it, edit first line of build.xml. added file platforms/android/cordovalib/build.xml added file platforms/android/cordovalib/proguard-project.txt project created. ~/desktop/test → cordova platforms ls installed platforms: android 3.5.0 available platforms: amazon-fireos, blackberry10, firefoxos, ios ~/desktop/test → cordova plugin add together org.apache.cordova.battery-status fetching plugin "org.apache.cordova.battery-status" via plugin registry installing "org.apache.cordova.battery-status" android ~/desktop/test → cordova plugin ls org.apache.cordova.battery-status 0.2.8 "battery" ~/desktop/test → then opening `~/desktop/test/www/index.html , changing this:
<script type="text/javascript"> app.initialize(); </script> to this:
<script type="text/javascript"> app.initialize(); console.log("here!"); window.addeventlistener("batterystatus", onbatterystatus, false); function onbatterystatus(info) { console.log("level: " + info.level + " isplugged: " + info.isplugged); } </script> then executing command:
~/desktop/test → cordova run android then seeing application launching on phone , when head chrome://inspect/ see don't see batter status. here's getting in browser console:
the key "target-densitydpi" not supported. index.html:25 here! index.html:43 received event: deviceready index.js:47 as see "here!" displayed not battery status. when wait phone battery percentage change.
what missing?
please help.
i create exact build described above , able create little alter worked:
you need move
window.addeventlistener('batterystatus', onbatterystatus, false); to app.ondeviceready. because window listener needs added after device apis have been loaded.
i found hidden in documentation:
applications typically should utilize window.addeventlistener attach event listener 1 time deviceready event fires.
cordova hybrid-mobile-app
Comments
Post a Comment