Android Question get calendar permission

SMOOTSARA

Active Member
Licensed User
Longtime User
Hi
I need to get the following access from the user
"android.permission.READ_CALENDAR"
"android.permission.WRITE_CALENDAR"


manifest:
B4X:
AddManifestText(
<uses-permission android:name="android.permission.READ_CALENDAR"/>
<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
)

B4X:
    RuntimePermissions1.CheckAndRequest("android.permission.READ_CALENDAR")
    wait for Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result = False Then
        Log("NO Permission READ Calendar")

xxxxxxxxxxxxxxxxxxxxxxxxxx
?  ?  ? I need to direct the user to the System/Settings/Apps/app X/ Calendar Permissions???
xxxxxxxxxxxxxxxxxxxxxxxxxx


    Else
        RuntimePermissions1.CheckAndRequest("android.permission.WRITE_CALENDAR")
        wait for Activity_PermissionResult (Permission As String, Result As Boolean)
        If Result Then
            canAccessCal = True
        End If
    End If


xxxxxxxxxxxxxxxxxxxxxxxxxx
? ? ? I need to direct the user to the System/Settings/Apps/app X/ Calendar Permissions???
xxxxxxxxxxxxxxxxxxxxxxxxxx

Thanks
 

drgottjr

Expert
Licensed User
Longtime User
there seem to be a couple ways (i found java examples, but b4a should be similar):
intent = new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS)
startActivity(intent)

startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0)

but if user has already said she doesn't want to grant permission, why would you send her to the settings? you might want to explain what's going on and then offer the chance to reconsider (and if she says OK, then run the intent). i usually tell people (who have not granted a permission) that certain features will not function unless they grant permission, which they can do at any time by going to system settings, etc. by automatically sending her to the settings, she just ends up going back to your app even if she still hasn't granted permission...
 
Upvote 0

SMOOTSARA

Active Member
Licensed User
Longtime User



Thank you for your response ?

I have given the user all the explanations

I need exactly this example but to get a permission for calendar

https://www.b4x.com/android/forum/threads/90513/#content
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
sorry. it's an intent for app permissions (Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS).
there is no particular system setting for calendar. you get to it through app permissions settings. i should have understood.

this link: https://www.b4x.com/android/forum/threads/startactiviti-intent.58869/#content

you can search for this stuff yourself, you know. between the forum and google, it's all out there.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…