Device not asking permission to use camera

I have a Samsung Galaxy 7 and testing an app to take a picture. When I run it I am prompted if I want to use the location service but nothing for the cameras. I have the permissions in just like the camera sample app. When I run the camera sample app it does prompt. Here is some of my code below. It always says the device does not have a camera.

local function btnCameraButtonEvent( event ) if ( "ended" == event.phase ) then if ( media.hasSource( media.Camera ) ) then local random = math.random local R2 = math.random( 1000, 9999 ) local File2 = "pic" .. os.time() .. R2 .. ".jpg" composer.setVariable( "PhotoName", File2 ) media.capturePhoto( { listener = onPhotoComplete, destination = { baseDir = system.TemporaryDirectory, filename = File2, type = "image" } } ) else native.showAlert( "Error", "This device does not have a camera.", { "OK" } ) end end end

-- -- For more information on build.settings see the Corona SDK Build Guide at: -- https://docs.coronalabs.com/guide/distribution/buildSettings -- settings = { orientation = { -- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight default = "portrait", supported = { "portrait", }, }, android = { usesPermissions = { "android.permission.CAMERA", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.READ\_EXTERNAL\_STORAGE", "android.permission.ACCESS\_FINE\_LOCATION", "android.permission.ACCESS\_COARSE\_LOCATION", }, usesFeatures = { { name = "android.hardware.camera", required = true }, { name = "android.hardware.camera.front", required = false }, }, }, excludeFiles = { -- Include only the necessary icon files on each platform iphone = { "Icon-\*dpi.png", }, android = { "Icon.png", "Icon-Small-\*.png", "Icon\*@2x.png", }, }, orientation = { default = "landscape", supported = { "landscape", } }, -- -- iOS Section -- iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-167.png", "Icon-60.png", "Icon-60@2x.png", "Icon-60@3x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small.png", "Icon-Small@2x.png", "Icon-Small@3x.png", "Icon-Small-40.png", "Icon-Small-40@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", }, }, }, }

Hi Warren,

If it’s a Galaxy 7, that means it must be Android 6.x, yes? Android 6 introduced a whole new way of handling permissions, so you need to take different steps in your code now. “media.hasSource()” now returns two booleans, not just one.

The best place to start is in the documentation, inspecting how it works and looking at the second example at the bottom.

https://docs.coronalabs.com/api/library/media/hasSource.html

In addition, this blog post sums up the Android 6 features which were introduced back in February:

https://coronalabs.com/blog/2016/02/16/introducing-new-android-6-features/

Hope this helps,

Brent

Gracias, esto funcionò!!

Hi Warren,

If it’s a Galaxy 7, that means it must be Android 6.x, yes? Android 6 introduced a whole new way of handling permissions, so you need to take different steps in your code now. “media.hasSource()” now returns two booleans, not just one.

The best place to start is in the documentation, inspecting how it works and looking at the second example at the bottom.

https://docs.coronalabs.com/api/library/media/hasSource.html

In addition, this blog post sums up the Android 6 features which were introduced back in February:

https://coronalabs.com/blog/2016/02/16/introducing-new-android-6-features/

Hope this helps,

Brent

Gracias, esto funcionò!!