Android的PhoneGap的 - navigator.camera未定义 [英] android phonegap - navigator.camera is undefined
问题描述
我完全陌生的PhoneGap。我开始与PhoneGap的构建 - 运行NPM安装-g PhoneGap的。
我的系统是Windows7的。
当我运行命令'PhoneGap的运行Android的我得到的控制台信息如下:
I'm completely new to phonegap. I started with phonegap build - by running 'npm install -g phonegap'. My system is windows7. When i run the command 'phonegap run android' i'm getting console messages as follows:
[phonegap] detecting Android SDK environment..
[phonegap] using the local environment
[phonegap] compiling Android...
[phonegap] successfully compiled Android app
[phonegap] trying to install app onto device
[phonegap] successfully installed onto device
我可以看到我的设备(索尼Xperia -E)上运行的应用程序。
但是,当我把我的javascript code:
I can see the app running on my device (sony Xperia -E). But when i put in my javascript code:
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicity call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
console.log('Received Event: ' + id);
//HERE
alert(navigator.camera)
}
我不断收到警告这不能不未定义。我检查与navigtaor.geolocation一样的,它不是不确定的。
i keep getting alert which say 'undefined'. I checked the same with navigtaor.geolocation, and it wasnt undefined.
我想这是与相机的插件。对吗?
I guess it something to do with camera plugin. Am i right?
请帮助
由于转发
推荐答案
您必须添加这些东西:
- >应用程序/ RES / XML / plugins.xml
--> app/res/xml/plugins.xml
<plugin name="Camera" value="org.apache.cordova.CameraLauncher" />
- >应用程序/ AndroidManifest
--> app/AndroidManifest
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
这篇关于Android的PhoneGap的 - navigator.camera未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!