I get the following exception when running on the new Samsung Galaxy 8 phones. The exception doesn't give me any information about what's causing it (as far as I can tell). I don't have an S8 phone to try to pinpoint the line of offending code.
Does anybody have any idea what the problem is or how to figure it out?
TIA
java.lang.SecurityException:
at android.app.ContextImpl.checkMode(ContextImpl.java:2323)
at android.app.ContextImpl.openFileOutput(ContextImpl.java:534)
at android.content.ContextWrapper.openFileOutput(ContextWrapper.java:192)
at com.yandex.metrica.impl.o.c(SourceFile:178)
at com.yandex.metrica.impl.o.a(SourceFile:44)
at com.yandex.metrica.impl.o$a.a(SourceFile:310)
at com.yandex.metrica.impl.o.b(SourceFile:164)
at com.yandex.metrica.impl.bh.c(SourceFile:139)
at com.yandex.metrica.impl.ag.c(SourceFile:145)
at com.yandex.metrica.impl.ag$a.run(SourceFile:295)
at com.yandex.metrica.impl.ob.bh.execute(SourceFile:10)
at com.yandex.metrica.impl.ob.bj.execute(SourceFile:7)
at com.yandex.metrica.impl.ag.run(SourceFile:86)
It might be due to a lack of permission.
Have you obtained storage permissions?
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Depending on the Android SDK that you are targeting, you might need to request the permission at runtime.
https://developer.android.com/training/basics/data-storage/files.html
Related
I am trying to add "HDMI connection" check in my app.
I referred to How to check the HDMI device connection status in Android? and decided to add the checks to read /sys/devices/virtual/switch/hdmi/state or if not, /sys/class/switch/hdmi/state files.
But I am getting:
java.io.FileNotFoundException
with "Permission denied". Do we need to request some permissions for this kind of access?
Thanks,
Vinay
I stumbled across the same problem.
resolve permissions problem
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
READ should be enough but if you grand Write works the same.
resolve runtime permmision problem - if you work with API 23+ you have to ask permission on runtime.
Root device - I had to root device to access sys/class/switch/*
I have an Android Cordova app and I'm using GPS, check the network state, read/write on the Documents folder and taking camera pictures. Here my permissions on the manifest XML file:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
The manifest file is auto generated by the Cordova framework. For some reason I don't see camera permissions. Permissions are not asked at installation time anymore (that's since Android 6) but instead they should be asked before usage.
I correctly get the GPS access permission popup but not the read/write Documents folder permission. I also never get the camera permission albeit I'm able to use it without ever being asked for permission. Same story for the Network status permissions (never being asked).
I find Android permissions scheme extremely confusing, under application manager my app has got Location and Storage as expected, Camera and Network status are missing though.
To recap, inside the app, on the actual code, I'm using at least once those devices
GPS fine grained
GPS coarse (probably the Wifi SSID triangulation trick)
Write on Documents
Read on Documents
Read network status (Offline / Wifi / 3G etc..)
Take picture from the camera
Cordova framework wrote this manifest file:
android.permission.ACCESS_COARSE_LOCATION
android.permission.ACCESS_FINE_LOCATION
android.hardware.location.gps (why is it not a .permission?)
android.permission.ACCESS_NETWORK_STATE
android.permission.WRITE_EXTERNAL_STORAGE
On application manager I get those options:
Location
Storage
So basically I get three different sets of permissions :-(
I found this in the this cordova plugin that you mentioned in comments.
So somehow this <uses-permission android:name="android.permission.CAMERA/> have to be in your code so as this plugin can use it.
Maybe you didn't check the right program to see its permissions, or if the camera permission is not shown in application permissions on device, you can't be able to use camera in this application. Please do a check again because I really want to know what is the situation.
I tried to run a simple camera OpenCV on mi 5. I installed the OpenCV_2.4.3_Manager_2.0_armeabi.apk but my mobile screen displayed 'It seems that your device does not support camera(or it is locked). Application will be closed' at the time of opening the app. How to resolve this issue?
Android 6.0 has introduced a new permission model. Application has to request the user for granting some permissions manually, declaration in Manifest is not enough.
More info here: https://developer.android.com/training/permissions/requesting.html
Going to: Settings -> Apps -> Your app -> Permissions and enabling the Camera permission
should also work, but might not be too elegant solution
Check in your manifest:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-feature android:name="android.hardware.camera.front"/>
<uses-feature android:name="android.hardware.camera.front.autofocus"/>
or, check in your device
Settings -> Apps -> Your app -> Permissions and enabling the Camera permission
or,
kill any other apps that are using the camera.
If those doesn't work! You device doesn't support openCV, not all devices support it!
I'm a newbie with android development. So far I have developed an application which uses SMSManager.
I'm testing my application on an active device when it reaches smsManager.sendTextMessage it throws exception of android.premission.SEND_SMS.
I know that I have to get device permission.
My Question is:
Can I send SMS while uploading application right from IDE, or have to install .apk manually?
You must add the following permissions in your Manifest file:
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
If you install the application via debugging/IDE/ADB it will automatically get the permissions you require in your manifest.
So: Yes! When run on the device through the debugger, the application will be able to send test messages.
Bonus information: If you do "stuff" that the application doesn't have the proper permissions for, the debugger will give you exceptions and hints to what is wrong.
I want to get udid of android emulator..How can i get it.Has anyone implemented it before?
Usually you can use TelephonyManager.getDeviceId() to get udid of a device, but if you are using Android emulator, it will return null. Docs here
Update:
You need to require READ_PHONE_STATE permission in your AndroidManifest.xml, i.e., by adding following line in the file:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />