I have an application that requires the user to either select a photo or take a picture and then upload that photo to a web service. IPhone, works fine, Android, no go.
The errors I get with Android are,
Camera -> Camera Cancelled,
Gallery -> Selection cancelled.
This error pops up even before the Camera/Gallery opens, they open, but it has already failed so it is pointless. The simulator does not catch this. I have not been able to test it on other Android devices, but the one I know it is braking with is: Droid Maxx.
Code Below:
var cur = SAMPLE.models.testOneOne;
$('#getPic').click(function () {
navigator.camera.getPicture(
function () {
alert('Success')
},
function (message) {
alert('Fail: ' + message);
}, {
saveToPhotoAlbum: false,
quality: 10,
destinationType: destinationType.FILE_URI,
sourceType: 0,
encodingType: 0,
mediaType: 0,
});
})
11 Answers, 1 is accepted
Thanks for contacting us.
I tried to reproduce your issue using our sample app on Nexus 4 Android 4.3, but of no avail. The API was working fine.
Would you try whether you will experience the same with our sample?
Regarding your app, I suggest debugging it on the device as described here and try it on another device if possible.
Furthermore, you can use an emulator and debug there for example to access the gallery.
If you need additional assistance I will be glad to help.
Regards,
Zdravko
Telerik
Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.
So, I was able to finally get the project loaded on the Droid X that we have, pain in the butt by the way, and it works just fine on it. Both the little test app and the actual application that this feature is used in.
As far as additional information on the Droid MAXX:
System Version: 21.11.21.obake-maxx)verizon.Verizon.en.US
System Information: Motorola X8 Mobile Computing System
Android Version: 4.4.4
Baseband version: MSM8960PRO_BP_232.55.52.00R
Kernal Version: 3.4.42-gb33f23d
hdsplat@ca101Inxdroid70 #1
I guess, as far as I can tell, it is just not compatible with this phone.
I have this tracked in a support ticket, but I will keep this line open in case they find an answer/workaround on that end so I can share it here.
I am closing this thread for now. You can reopen it at any time, by replying/posting in it. I suggest we continue the discussion in your support ticket on the same matter and update this thread after a solution is found.
Regards,
Kaloyan
Telerik
Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.
I am sorry to hear you have hit a similar issue when taking picture.
Testing the scenario on my side, I am afraid I could not observe any problem - the picture is taken and displayed on the device as expected.
In order to be able to advice you further, may I ask you to share some additional information:
- Do you experience the same with the Camera Sample?
- Are there any specific errors listed if you try Debugging on Device?
- Does the issue occur on a specific mobile OS or on any?
- Would you try running the app on a different Android device just so we can rule out the exact device module as a cause?
Looking forward to hearing from you.
Regards,
Dimitrina
Telerik
Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.
Hi Dimitrina,
The phone will simple kill my application after I click the check mark after selecting the picture from the Camera or the Photo Library.
It's probably not the problem of Cordova plugin, rather it's the problem of the phone itself. I deployed the app from tutorial https://ccoenraets.github.io/cordova-tutorial/handlebars-templates.html and the camera worked. After a month the camera doesn't work on this project either.
Following are my code:
=============Controller
var getImage = function(){
console.log(msg+"getImage - start");
CameraService.getPicture(options).then(
function(res){
console.log(msg+"getImage success with res:");
// $scope.member.face = "Jeff_Wang.jpg";
if(res==="" ||res===undefined){
showTipMsg();
console.log(msg+"getImage, success res='"+res+"' -- image unchanged");
}
else{
vm.member.face="data:image/jpeg;base64,"+res;
picDirty=true;
checkDirty();
console.log(msg+"getImage, success image.length:"+res.length);
}
}
,function(err){
showTipMsg();
console.err(msg+"getImage with error: "+err+" -- use original image: "+vm.member.face);
}
=================Services
.factory('CameraService', function(CameraNotAvailable,CameraAvailable) {
var msg = "services - .factory('CameraService')::: ";
if (navigator.camera) {
console.log(msg+"has camera");
return CameraAvailable;
} else {
console.log(msg+"has NO camera")
return CameraNotAvailable;
}
})
.service('CameraAvailable',['$q', function($q) {
var msg = "service('CameraAvailable'::: ";
console.log(msg+"Start");
return {
getPicture: function(options) {
var q = $q.defer();
navigator.camera.getPicture(function(result) {
// Do any magic you need
q.resolve(result);
console.log(msg+"resolve");
}, function(err) {
console.log(msg+"err");
q.reject(err);
}, options);
return q.promise;
}
}
}])
I tried to debug it and the debugger stopped at following line with null: org.apache.cordova.CordovaInterfaceImpl
public void setActivityResultCallback(CordovaPlugin plugin) {
// Cancel any previously pending activity.
if (activityResultCallback != null) {
activityResultCallback.onActivityResult(activityResultRequestCode, Activity.RESULT_CANCELED, null);
}
activityResultCallback = plugin; *********** activityResultCallback = null here
}
Have you eventually checked the "Don't keep activities" option in developer option menu of your phone? If so, please unselect it. Also, would you confirm you distribute and install the app on the device and not test it in the AppBuilder Companion App?
Since the behavior replicates on your side, you can try :
- using the adb tool that comes with the Android SDK to examine the device logs. They should have captured the exact error causing the app to crash.
- running the app on a different Android device just so we can rule out the exact device module as a cause.
In case the issue still persists, would you please send us the sample app as you are testing on, so that I can verify the exact case on my side?
Looking forward to hearing from you.
Regards,
Dimitrina
Telerik
Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.
Hi Dimitrina,
The un-check on the Don't keep activities option fixed the problem. I can take pictures using the app.
Thanks very much!