Many apps have their strings (in many languages) in strings.xml. Can we get some of their string values?
If we run this...
...we'll get something like "Allow all the time", depending on the language of the device and API level (should be at least 30).
This is the code for getBackgroundPermissionOptionLabel, used above:
And here are the strings.xml that getBackgroundPermissionOptionLabel get values from:
And here are the list of languages that the file exist in:
My question: Using the example code above, is it possible to use JavaObject (or something like that) get some other string, in the language of the device? (And I'm only focused on strings for PermissionController.)
If we run this...
B4X:
Dim ctxt As JavaObject
ctxt.InitializeContext
ctxt.InitializeArray
Dim PackageManager As JavaObject = ctxt.RunMethod("getPackageManager", Null)
Log(PackageManager.RunMethod("getBackgroundPermissionOptionLabel", Null))
This is the code for getBackgroundPermissionOptionLabel, used above:
B4X:
public CharSequence getBackgroundPermissionOptionLabel() {
try {
String permissionController = getPermissionControllerPackageName();
Context context =
mContext.createPackageContext(permissionController, 0);
int textId = context.getResources().getIdentifier(APP_PERMISSION_BUTTON_ALLOW_ALWAYS,
"string", PERMISSION_CONTROLLER_RESOURCE_PACKAGE);
if (textId != 0) {
return context.getText(textId);
}
} catch (NameNotFoundException e) {
Log.e(TAG, "Permission controller not found.", e);
}
return "";
}
And here are the strings.xml that getBackgroundPermissionOptionLabel get values from:
And here are the list of languages that the file exist in:
My question: Using the example code above, is it possible to use JavaObject (or something like that) get some other string, in the language of the device? (And I'm only focused on strings for PermissionController.)