Android Question HTTPServer - Runtime Permission

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am using the HfTTPServer (version 1.00) library in my B4A app - https://www.b4x.com/android/forum/t...er-in-your-android-application.25984/#content

I have noticed that it requires an Runtime Permission (android.permisssion.WRITE_EXTERNAL_STORAGE).

Is there a way in changing it so it doesn't need this runtime permission? Maybe making it use
File.DirInternal so it doesn't require the runtime permission?

From what I can see, it is built into the HTTPServer library.
 

aaronk

Well-Known Member
Licensed User
Longtime User
Try this:

1. Add to manifest editor: RemovePermission(android.permission.WRITE_EXTERNAL_STORAGE)
2. Add to manifest editor the snippet required for RuntimePermissions.GetSafeDirDefaultExternal.

Unless I am doing it wrong, it didn't work.

Here is what my manifest looks like:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetActivityAttribute(Main, "android:excludeFromRecents", "true")
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddPermission(android.permission.INTERNET)
'End of default text.

AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="18" />
)

RemovePermission(android.permission.WRITE_EXTERNAL_STORAGE)

In my Starter Service I have:
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
        Dim rp As RuntimePermissions
End Sub

I have a Service called 'WebServer' and in that service I have:
B4X:
Sub Service_Create
 
    Starter.rp.GetSafeDirDefaultExternal("")
    server.Initialize("Server")
    server.Start(5555)
 
End Sub

When I view the Permissions from the 'List Permissions' from the log tab in the IDE it still shows it requires the permission.

Should it remove that permission from the 'List Permissions' dialog or will it still run fine even knowing it shows that permission ?

3. Call RuntimePermissions.GetSafeDirDefaultExternal("") before you initialize the server.
Is the code above correct on how to call this ?
 
Upvote 0
Top