runtime-permissions

checkSelfPermission() doesn't seem to work for WRITE_EXTERNAL_STORAGE

隐身守侯 提交于 2020-01-02 08:34:14
问题 I have the app that uses <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> It's automatically granted on Android 6.0, but I can revoke it in the settings. Wanted to check if it's granted in case user revokes it, so I do this: int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE); if (permissionCheck == PackageManager.PERMISSION_GRANTED) { //OK permission granted, let's do stuff } else { //I'll better ask for

Understanding the Android 6 permission method

眉间皱痕 提交于 2019-12-30 20:31:13
问题 I am trying to take an image from Gallery and set it to an imageview but in Android 6 there are some permission problems. Below is the method to ask for the permission. Should I ask for read external storage or write external storage? Here is what I have done so far: private static final int READ_CONTACTS_PERMISSIONS_REQUEST = 1; public void getPermissionToReadExternalStorage() { if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager

Runtime Permission on android marshmallow

别说谁变了你拦得住时间么 提交于 2019-12-25 07:46:34
问题 I would like to know whether the runtime permission popup is visible or not in the activity. How can i know that? Is there any callback or overrided method for the same. 回答1: You request permissions yourself so you know when it is shown. You can also add a result callback. See the code below; public void requestPermissions(List<String> permissions, ActivityCompat.OnRequestPermissionsResultCallback onRequestPermissionsResultCallback) { String[] params = permissions.toArray(new String

Android permission to read a file from SD card issues

梦想的初衷 提交于 2019-12-24 20:16:43
问题 Hi I try to read a file from SD card from Android app. In my AndroidManiest.xml file I already specify permission on read and write on external storage <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> Here is my code to check permission and try to read a file in the MainActivity.java. But I was not able to read my file. What did I do wrong ? Please help! int ReadExternalStoragePermission =

Getting FileNotFoundException on Android app after denying and than granting permission at runtime

青春壹個敷衍的年華 提交于 2019-12-24 02:18:31
问题 I'm trying to to get an app to play an mp3 from the sd card. I'm using the android sdk version 23, with Android studio on Windows 8. I'm running this on the nexus 5 emulator. I'm requesting permission at runtime and I'm getting a FileNotFoundException if I deny the permission once but than grant the permission on the second request. If I restart the app, I'm able to play the music file and if I accept the permission request on the first try it also successfully plays the music without

Can i skip asking Runtime Permissions on marshmallow?

二次信任 提交于 2019-12-23 15:14:33
问题 Now this is something very interesting for me, I know mostly about Runtime Permissions and i am well aware of why Runtime Permissions proposed? and How we can use it? but in this question which is about a problem rising due to this run time permission thing, A guy proposed a pretty newer way to solve this problem. See U.swap's answer on the same question,here is that answer. This guy Proposed a nice and working solution that user have to approve Permissions only once and for rest of his life

Can't turn on location on android api23?

丶灬走出姿态 提交于 2019-12-20 05:38:16
问题 I have used the following code and the dialogue that asks for permission shows as expected. But when I click "allow" it doesn't do anything. The log message doesn't appear as if the permission wasn't granted so I went to my parameters to verify if location is "on" and it was "off". Wasn't it supposed to be on because I granted the app access to my location ? If I manually turn it "on" and then run the app again, once it asks for my permission, it works and shows the log message but isn't the

Asking for permissions at run-time, Android M+

泄露秘密 提交于 2019-12-19 19:49:25
问题 Firstly, I know this is a duplicate question, but I've been over the answers from other similar questions and haven't been able to find success with any of those solutions. I've developed an app which works perfectly on my testing device which is a Samsung S4 running Android L (5.0.1) however I would like for this app to also work on newer versions of Android. I understand that requesting permissions have changed for Android M+ so that they have to be asked at run-time, but when I try to

How to ask runtime permissions for Camera

此生再无相见时 提交于 2019-12-17 19:22:20
问题 I am doing an application to scan barcodes on a button click and it was working fine up to Lollipop versions. When I came to Marshmallow it stopped working. This is the error: camerabase an error occurred while connecting to camera 0 It forces me to turn on permission by: Settings --> application --> my app --> camera. My question is how to allow camera permission to my app automatically in Marshmallow or by asking the user to turn on camera at runtime. A screen shot: 回答1: Below I have

Calling WifiManager.startLocalOnlyHotspot() throws SecurityException even after granting all required permissions on some devices

允我心安 提交于 2019-12-13 03:14:04
问题 I am working on a file sharing app. I need to turn on local only hotspot of a device programmatically by calling WifiManager.startLocalOnlyHotspot(). According to the android docs on this page - https://developer.android.com/reference/android/net/wifi/WifiManager#startLocalOnlyHotspot(android.net.wifi.WifiManager.LocalOnlyHotspotCallback,%2520android.os.Handler), Applications need to have the following permissions to start LocalOnlyHotspot: Manifest.permission.CHANGE_WIFI_STATE and ACCESS