Android Question Manifest and Permissions

udg

Expert
Licensed User
Longtime User
Hi all,

I am updating an old library of mine (pure B4A code, no java), and following @Erel directions on how to safely update an apk I placed the following lines in my lib's Manifest file

B4X:
'GetSafeDirDefaultExternal needs this for older versions
AddManifestText(<uses-permission
   android:name="android.permission.WRITE_EXTERNAL_STORAGE"
   android:maxSdkVersion="18" />
)

AddPermission(android.permission.REQUEST_INSTALL_PACKAGES)

while those about the FileProvider went to the app's Manifest.
Everything seems to work ok whether I keep these permission-related lines only in lib, only in app, both in lib and app.

Why I'd like to keep permissions lines in my lib's manifest? Because a class in it makes use of GetSafeDirDefaultExternal to find a place where to save a temporary file which is later used to update an apk. And I feel more comfortable to keep them close to where they are needed.

My question is: should I necessarily have to move those lines to the app's Manifest or it's ok to keep them within the lib, letting the user to cope just with FileProvider lines as per the link showed above?

TIA
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Developers using your library will need to add this snippet:
B4X:
AddManifestText(<uses-permission
   android:name="android.permission.WRITE_EXTERNAL_STORAGE"
   android:maxSdkVersion="18" />
)
It will not be included in the library XML as it is not a standard permission. This permission is only added to Android 4.3- devices. It is not needed on Android 4.4+.

Tip about FileProvider, there is a new class available: [class] FileProvider - share files
It is better than the older CreateFileUri code.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Thanks Erel.
So, what you suggest is to let the developer insert all the needed snippets in his/her own app's Manifest, while I should limit myself at clearly list what he/she needs to include; right?

A strictly related question. Considering a library as a container for some classes and services, it's wrong to assert that its Manifest could be empty?
We know that Main and Starter are discarded when compiling to a lib, so it is safe to consider that manifest ignored too?
In other words, is the main app's manifest the only one significant?

TIA
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…