sadegh nordeh
Member
Hello B4X Team,
Currently, B4A does not support AndroidX’s modern `registerForActivityResult` API.
This limitation makes it difficult to reliably receive results from Activities, such as VPN permission requests, without occasionally losing the callback.
At the moment, B4A developers must use `IOnActivityResult`, which works most of the time but can fail in certain devices or Android versions, showing the log: "onActivityResult: IOnActivityResult was released".
Supporting `registerForActivityResult` or `ActivityResultLauncher` in B4A would bring several benefits:
1. Reliable handling of Activity results and permissions.
2. Full compatibility with modern AndroidX APIs.
3. Cleaner and more robust code for Activity result handling.
Example of modern Android code that cannot currently be used in B4A:
Thank you!
Currently, B4A does not support AndroidX’s modern `registerForActivityResult` API.
This limitation makes it difficult to reliably receive results from Activities, such as VPN permission requests, without occasionally losing the callback.
At the moment, B4A developers must use `IOnActivityResult`, which works most of the time but can fail in certain devices or Android versions, showing the log: "onActivityResult: IOnActivityResult was released".
Supporting `registerForActivityResult` or `ActivityResultLauncher` in B4A would bring several benefits:
1. Reliable handling of Activity results and permissions.
2. Full compatibility with modern AndroidX APIs.
3. Cleaner and more robust code for Activity result handling.
Example of modern Android code that cannot currently be used in B4A:
I hope this feature can be added in a future update, improving reliability and modern Android support in B4A.ActivityResultLauncher<Intent> vpnLauncher = activity.registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
new ActivityResultCallback<ActivityResult>() {
@Override
public void onActivityResult(ActivityResult result) {
boolean granted = result.getResultCode() == Activity.RESULT_OK;
// Handle the result
}
}
);
Thank you!