Phonegap Error - “Unable to read capture of undefined property on Android

Trying to create an application to launch using PhoneGap. I am stuck on this line:

navigator.device.capture.captureAudio(onSuccess, onError, {limits:1, duration:5});

It works fine on iOS, but generates this error on the Android emulator:

Unable to read "capture" of undefined property

Here is the navigatorobject during the error (note that there is no property devicecausing this error)

{
    "language": "en-US",
    "product": "Gecko",
    "mimeTypes": {
        "length": 0
    },
    "appVersion": "5.0 (Linux; U; Android 4.0.3; en-us; sdk Build/MR1) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
    "plugins": {
        "length": 0
    },
    "onLine": true,
    "connection": {
        "type": 0
    },
    "platform": "Linux armv7l",
    "vendor": "Google Inc.",
    "appCodeName": "Mozilla",
    "geolocation": {},
    "cookieEnabled": true,
    "appName": "Netscape",
    "productSub": "20030107",
    "userAgent": "Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; sdk Build/MR1) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
    "vendorSub": ""
}

And here the object loaded PhoneGapright after Phonegap.js(note what it says device: true)

{
    "commandQueue": [],
    "commandQueueFlushing": false,
    "_constructors": [
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null
    ],
    "documentEventHandler": {},
    "windowEventHandler": {},
    "resources": {
        "base": true,
        "debugconsole": true,
        "position": true,
        "acceleration": true,
        "accelerometer": true,
        "battery": true,
        "camera": true,
        "device": true,
        "capture": true,
        "contact": true,
        "file": true,
        "filetransfer": true,
        "geolocation": true,
        "compass": true,
        "media": true,
        "notification": true,
        "orientation": true,
        "sms": true,
        "telephony": true,
        "network": true,
        "splashscreen": true
    },
    "available": false,
    "sessionKey": 0,
    "callbackId": 0,
    "callbacks": {},
    "callbackStatus": {
        "NO_RESULT": 0,
        "OK": 1,
        "CLASS_NOT_FOUND_EXCEPTION": 2,
        "ILLEGAL_ACCESS_EXCEPTION": 3,
        "INSTANTIATION_EXCEPTION": 4,
        "MALFORMED_URL_EXCEPTION": 5,
        "IO_EXCEPTION": 6,
        "INVALID_ACTION": 7,
        "JSON_EXCEPTION": 8,
        "ERROR": 9
    },
    "mediaObjects": {}
}

Any ideas how to get past this?

+5
source share
2 answers

Well, this is the strongest decision I've ever stumbled upon!

JS Android , iOS. , - phonegap-x.x.x.js. , .

, JS , -?

JS Android, .

: deviceready Phonegap 1.0.0 Android

+2

phonegap.js www- index.html? phonegap.js phonegap-1.3.0.js, API HTC evo

0

All Articles