tidev / ti.barcode

QR and Barcode Scanner
Other
66 stars 90 forks source link

Android 6 not working #25

Closed beaur closed 8 years ago

beaur commented 8 years ago

On a device running Android 6, when the app tries to use the camera to scan the message "Sorry, the Android camera encountered a problem. You may need to restart the device." is shown and the camera cannot be used.

ashcoding commented 8 years ago

Related to https://jira.appcelerator.org/browse/MOD-2168

Due to the new Permission System in Android 6.0, you would need to use

Ti.Media.requestCameraPermissions
ashcoding commented 8 years ago

The code that needs to be added would be:-

if (Ti.Media.hasCameraPermissions()) {
    window.open();
} else { 
    Ti.Media.requestCameraPermissions(function(e) {
             if (e.success === true) {
                 window.open();
             } else {
                 alert("Access denied, error: " + e.error);
             }
    });
}
levieraf commented 8 years ago

works for me with your code @ashcoding

thanks!!!

ashcoding commented 8 years ago

Closing issue.

blueice349 commented 8 years ago

Is there anything else with the new android permissions that this may be needed to be added to?

ashcoding commented 8 years ago

@blueice349 any thing in particular you are referring to?

blueice349 commented 8 years ago

Just trying to find out what else will require a permission change in android. Now know Camera does. We also use Signature fields and GPS a lot will GPS require any permission changes?

ashcoding commented 8 years ago

@blueice349 GPS would require you to request for permissions as well on Android 6.0 You can refer here: http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation-method-requestLocationPermissions

Related doc: http://developer.android.com/training/permissions/requesting.html If there's a permission that you can't request for in Android 6.0, you can create a Jira ticket for it to be addressed.