We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I know that onActivityResult deprecated but still used in next API versions. But I suggest to upgrade to consistent with newer API.
onActivityResult
Old way (Kotlin)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { @Suppress("DEPRECATION") super.onActivityResult(requestCode, resultCode, data) getViewBinding().advancedWebView.onActivityResult(requestCode, resultCode, data) }
New way (Kotlin)
private val mOnWebViewActivityResult = registerForActivityResult( ActivityResultContracts.StartActivityForResult() ) { result -> getViewBinding().advancedWebView.handleActivityResultCallback(result) }
The text was updated successfully, but these errors were encountered:
Thanks!
We might, at some point, switch to the new API, but that is absolutely low-priority.
More information on the API is available here as well: https://developer.android.com/training/basics/intents/result
Sorry, something went wrong.
Can you provide new way in java fragment code?
@mhemon did you solve using the new way in java?
you can change original code with this:
public void setListener(final Fragment fragment, final Listener listener, final int requestCodeFilePicker) { if (fragment != null) { mFragment = new WeakReference<Fragment>(fragment); mSelectFileResultLauncher = mFragment.get().registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { onActivityResult(requestCodeFilePicker, result.getResultCode(), result.getData()); }); } else { mFragment = null; } setListener(listener, requestCodeFilePicker); }
if (mFragment != null && mFragment.get() != null && Build.VERSION.SDK_INT >= 11) { mSelectFileResultLauncher.launch(i); // mFragment.get().startActivityForResult(Intent.createChooser(i, getFileUploadPromptLabel()), mRequestCodeFilePicker); } else if (mActivity != null && mActivity.get() != null) { mActivity.get().startActivityForResult(Intent.createChooser(i, getFileUploadPromptLabel()), mRequestCodeFilePicker); }
No branches or pull requests
I know that
onActivityResult
deprecated but still used in next API versions. But I suggest to upgrade to consistent with newer API.Old way (Kotlin)
New way (Kotlin)
The text was updated successfully, but these errors were encountered: