Android Question Removing permission

Sergey_New

Well-Known Member
Licensed User
Longtime User
When opening the application, two permissions are set:
PERMISSION_WRITE_EXTERNAL_STORAGE
PERMISSION_READ_CONTACTS
Is it possible to remove and install the PERMISSION_READ_CONTACTS permission at the user's discretion?
Or do you just need to uninstall and reinstall the application?
 
Solution
To remove the contact permission, instead of having the user uninstall the app (and thus loose all its settings) and then reinstall it and deny the contacts, you could simply programically bring the user to your apps info screen and allow them to manually remove the contact permission.

Here is ChatGPT info on that...

Here’s how you can do it in a B4A app:
  1. Intent to Open the App Settings: You need to create an intent that targets the Android system settings for your specific app. The intent uses the ACTION_APPLICATION_DETAILS_SETTINGS of the Android settings.
  2. Implementing the Intent: You can use the following B4A code snippet to launch the app settings screen:
B4X:
Sub OpenAppSettings()...

JohnC

Expert
Licensed User
Longtime User
To remove the contact permission, instead of having the user uninstall the app (and thus loose all its settings) and then reinstall it and deny the contacts, you could simply programically bring the user to your apps info screen and allow them to manually remove the contact permission.

Here is ChatGPT info on that...

Here’s how you can do it in a B4A app:
  1. Intent to Open the App Settings: You need to create an intent that targets the Android system settings for your specific app. The intent uses the ACTION_APPLICATION_DETAILS_SETTINGS of the Android settings.
  2. Implementing the Intent: You can use the following B4A code snippet to launch the app settings screen:
B4X:
Sub OpenAppSettings()
    Dim intent As Intent
    intent.Initialize(intent.ACTION_APPLICATION_DETAILS_SETTINGS, "package:" & Application.PackageName)
    StartActivity(intent)
End Sub

This code does the following:
  • Initializes an intent with ACTION_APPLICATION_DETAILS_SETTINGS. This action shows the application details settings screen.
  • Sets the data URI to your app's package name, which is necessary to direct the user specifically to your app's settings.
  • Starts the activity using StartActivity, which will open the settings screen.
  1. Usage: You can call this method (OpenAppSettings) from anywhere in your app where you deem it appropriate, such as after a user has denied a permission request or from a settings/help screen within your app that explains permissions.
By opening the app settings screen, users can manually enable or disable permissions as they prefer. This approach respects user autonomy while providing them an easy path to manage app permissions.
 
Upvote 0
Solution

Sergey_New

Well-Known Member
Licensed User
Longtime User
Вот как это можно сделать в приложении B4A:
Thank you!
Following your example, I found Open app details page in settings app
B4X:
Private Sub OpenAppSettingsPage
    Dim in As Intent
    in.Initialize("android.settings.APPLICATION_DETAILS_SETTINGS", "package:" & Application.PackageName)
    Try
        StartActivity(in)
    Catch
        Log(LastException)
        ToastMessageShow("Failed to open settings app", True)
    End Try
End Sub
 
Upvote 0
Top