William Hunter Active Member Licensed User Longtime User May 1, 2017 #1 This is my first experience with the new runtime permissions. I am using KeyValueStore to store settings info in File.DirDefaultExternal. I want to make “datastore” available over SDK versions 16 to 25. Below is how I am attempting to do this. Is this the correct way, or should I handle this differently? Any help greatly appreciated. Regards Code: If FirstTime Then kvs.Initialize(File.DirDefaultExternal, "datastore") rp.CheckAndRequest(rp.PERMISSION_CAMERA) rp.CheckAndRequest(rp.PERMISSION_RECORD_AUDIO) rp.GetSafeDirDefaultExternal("datastore") End If Added this to manifest. Code: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" /> EDIT: This seems to work, but DirInternal might be just as good. Code: If FirstTime Then Dim Dir As String = rp.GetSafeDirDefaultExternal("") 'safe dir device dependent kvs.Initialize(Dir, "datastore") 'init keyvaluestore rp.CheckAndRequest(rp.PERMISSION_CAMERA) rp.CheckAndRequest(rp.PERMISSION_RECORD_AUDIO) End If Last edited: May 1, 2017
This is my first experience with the new runtime permissions. I am using KeyValueStore to store settings info in File.DirDefaultExternal. I want to make “datastore” available over SDK versions 16 to 25. Below is how I am attempting to do this. Is this the correct way, or should I handle this differently? Any help greatly appreciated. Regards Code: If FirstTime Then kvs.Initialize(File.DirDefaultExternal, "datastore") rp.CheckAndRequest(rp.PERMISSION_CAMERA) rp.CheckAndRequest(rp.PERMISSION_RECORD_AUDIO) rp.GetSafeDirDefaultExternal("datastore") End If Added this to manifest. Code: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" /> EDIT: This seems to work, but DirInternal might be just as good. Code: If FirstTime Then Dim Dir As String = rp.GetSafeDirDefaultExternal("") 'safe dir device dependent kvs.Initialize(Dir, "datastore") 'init keyvaluestore rp.CheckAndRequest(rp.PERMISSION_CAMERA) rp.CheckAndRequest(rp.PERMISSION_RECORD_AUDIO) End If
Erel B4X founder Staff member Licensed User Longtime User May 2, 2017 #2 Your code is correct. If the camera is not needed immediately when the program starts then it is better to ask for the permission later when it is required. Upvote 0
Your code is correct. If the camera is not needed immediately when the program starts then it is better to ask for the permission later when it is required.