Manifest file:
<uses-permission android:name="android.permission.CAMERA" android:requiredFeature="true" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:requiredFeature="true" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:requiredFeature="true"/>
The app does not request the camera permissions but it is still working.
I am able to use the camera using the following intent:
val takePhotoIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
I am not sure why.
This is despite the fact that no permissions are granted to the app:
The reason this works is that your app is not getting access to any of:
The camera itself
The user's internal/external storage
The user's existing photos
All you're getting is the opportunity to ask the user to take a photo and return that photo to you. Because the user needs to affirmatively consent as part of the process, no permission is required.
This model also has the benefit of allowing apps to capture photos even if the user would not entrust them with camera or storage permissions. They can rest assured that the app only got access to the single photo that the user took. The same principle applies when asking the user to select a photo as well.
I think this is because you're not actually getting control of the camera yourself. You're asking to launch the camera app. There's no way in this for your app to take a photo without user intervention, so it's safe.
It's maybe because you are running it on an older api or have already gave these privileges to the app for once. The other possibility: your device is rooted.
Related
I have requested below two permissions in app,
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO " />
Then I allow the permissions, and verify from 'App permissions'
But, the app still dont have the READ_MEDIA_VIDEO permission, e.g the below code return false. And the app cannot access/read the videos from device.
ContextCompat.checkSelfPermission(
context!!,
Manifest.permission.READ_MEDIA_VIDEO
) == PackageManager.PERMISSION_GRANTED
If your app only needs to access images, photos, and videos, consider using the photo picker instead of declaring the READ_MEDIA_IMAGES and READ_MEDIA_VIDEO permissions.
More details available here
According to Google storage documentation. It seems that for non-media files no permission is needed.
I uploaded an android photo compress application in play store and I checked every thing is ok, but some users have issue that the application can not save compressed photos, I checked that and I found this error
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FileSystemException: Cannot create file, path = '/storage/emulated/0/My Folder/photo.jpg' (OS Error: Operation not permitted, errno = 1)
This is permissions AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA"/>
This line inside application tag
android:requestLegacyExternalStorage="true"
I looked for some solutions and founded this permission line
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
But when ask for this permission android shows to user warning the application will access to all files without asking permission, I feel this is worrying for users and some may be afraid of this permission, however I uploaded the application but it was rejected because using MANAGE_EXTERNAL_STORAGE permission.
you are right regarding MANAGE_EXTERNAL_STORAGE permission. Your app will be removed from play store if you don't have valid reasons. You may have to create a video and explain why you need these permission, and how scoped storage can't help you.
Now, you should know one thing that you are trying to create a folder directly inside internal storage. This will work in lower android versions but will fail in Android 10 or above even when you have WRITE_EXTERNAL_STORAGE granted.
Try creating your files inside public directories like Download or Documents. If the files downloaded doesn't need to be accessed by users then you can always save in your package folder context.getExternalFilesDir(null)
Hope this helped you! If you have any further doubts feel free to comment down below.
In Android 0, apps that want the capability of installing apk's must be specifically granted that permission by the user in the system settings. However, I havent been able to figure out how to get my app into the list of apps the user can pick from.
Can anyone point me in the right direction?
Thanks
Probably this blog post will help:
https://android-developers.googleblog.com/2017/08/making-it-safer-to-get-apps-on-android-o.html
To sum it up:
Need to declare the permission in your manifest <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
Before install you should check if the permission is still granted (PackageManager.canRequestPackageInstalls()), if not you can request it again using
Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
intent.setData(Uri.parse("package:YOURPACKAGENAME"));
I am trying to show a live preview of the rear facing camera in Codename One. I use for that the native interface (I am targetting Android first).
To allow my app to use the camera without messing up with build hints, I added these lines in my Main Form :
if (Capture.hasCamera()){
Dialog.show("Appareil photo détecté", "Votre matériel est bien équipé d'un appareil photo!", "OK", null);
}
I did that because Codename One blog stated
android.hardware.camera & android.permission.RECORD_AUDIO - are triggered by com.codename1.Capture
However while debugging the app with the sources I got from CN1 under Android Studio on a real device (API LEVEL 19 aka Kit Kat) I always got a java.lang.RuntimeException: Fail to connect to camera service.
After a while I realized that the exception was due to the lack of the following permission in manifest.xml :
<uses-permission android:name="android.permission.CAMERA" android:required="false"/>
Please note that as stated in CN1 blog the line <uses-feature android:name="android.hardware.camera" android:required="false" /> was already added by CN1.
Now that I've added this line the live preview is well shown.
Why is this permission not automatically added in the manifest, should I really add it to the build hint ?
Moreover I have another project that uses the Camera to take photo and save them on the phone and the Camera permission is neither shown (in Android Application Info) nor requested during app installation whereas it works perfectly well. Please note that e.g. Twitter App shows "Take photos and record videos" in the app permissions so it does not seem to be a problem with my phone hiding camera permission.
EDIT November 20th 2016 :
Indeed Android Developer's guide states that
Note: If you are using the camera by invoking an existing camera app, your application does not need to request this permission.
That's why CN1 does not require this permission!
Thanks for helping me getting the permission management with CN1 right.
You need to add the following build hint:
android.xpermissions=<uses-permission android:name="android.permission.CAMERA" android:required="false"/>
You can also add this to the cn1lib so it is injected automatically.
In the past, you add the permission you want to your manifest and then it is requested when your user attempts to install your app. As of Android 6.0+, this has changed. Now you can just request a permission when your app needs it for the first time. After the user grants you permission, you don't need to ask again next time. Some benefits of this include keeping your user aware of why you need specific permissions and not requesting permissions that you don't actually need.
You can read more about how to implement it here: https://developer.android.com/training/permissions/requesting.html
There is no way to use a phones camera without asking for permission at some point.
I have the following permission in my manifest:
<uses-permission android:name="android.permission.CAMERA" />
Is this the reason users without cameras on their devices can't download my apps from Google Play?
Is there a way to make this permission OPTIONAL? Meaning... I need to use your camera, but if you don't have one, you can still use my app anyway.
Per the Permissions that Imply Feature Requirements page CAMERA implies android.hardware.camera. You can make it optional by including
<uses-feature android:name="android.hardware.camera" android:required="false" />
I have found a good article which says what is in accepted answer but also adds information how to handle situation when user trys to open camera-related-feature but there is no camera.
Simple code from the article:
// Check that the device will let you use the camera
PackageManager pm = getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
// Do camera stuff...
}