Phonegap navigator.device issue android

2019-08-28 20:46发布

问题:

I have some problems with camera and geolocation in my app. WHen i try to use navigator.camera.getPicture or navigator.geolocation.getCurrentPosition, happens nothing. Here is my code

options.sourceType = navigator.camera.DestinationType.PHOTOLIBRARY;
options.destinationType navigator.camera.PictureSourceType.FILE_URI;

alert(1);
navigator.camera.getPicture(
            function (data) { // Success!
                alert(4);
                self._mediaDataSuccess(data);
            }
            ,
            function (error) { // Fail!
                alert(5);
                self._mediaDataFail(error);
            },
            options
        );
alert(2);

At first i see message box with 1, then with 2. I haven't see 4 or 5. All permissions enabled.

Also, i have same code for navigator.geolocation.getCurrentPosition, with same problem.

Where is my mistake?