Skip to content

Crash in onActivityResult on Production #4

Open
@Mutant-Slayer

Description

@Mutant-Slayer

I am getting following crash in onActivityResult function, not able to reproduce it but affecting lots of user on production.

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1776018257, result=0, data=Intent { (has extras) }} to activity {com.vlv.aravali.reels/com.vlv.aravali.login.LoginActivity}: java.lang.RuntimeException: Please call init() on TcSdk first at android.app.ActivityThread.deliverResults(ActivityThread.java:4458) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4500) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1839) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:201) at android.app.ActivityThread.main(ActivityThread.java:6861) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

This is the code of onActivityResult

`override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)

    if (resultCode == Activity.RESULT_OK) {
        when (requestCode) {

            TcSdk.SHARE_PROFILE_REQUEST_CODE -> {
                tcSdkOptions?.let {
                    EventsManager.setEventName(EventConstants.TRUECALLER_REQUEST_RESULT_CODE)
                        .addProperty(BundleConstants.SCREEN_NAME, TAG)
                        .addProperty(BundleConstants.RESULT_CODE, resultCode)
                        .addProperty(BundleConstants.REQUEST_CODE, requestCode)
                        .addProperty(BundleConstants.IS_INTERNAL_LOGIN, mIsInternalLogin)
                        .addProperty(BundleConstants.SOURCE, mLoginDialogSource)
                        .send()
                    if (TcSdk.getInstance() != null) {
                        TcSdk.getInstance().onActivityResultObtained(requireActivity(), requestCode, resultCode, data)
                    }
                }
            }
        }
    }
}`

How can I avoid it, I have added this check if (TcSdk.getInstance() != null) {} right now to avoid it
Is there any other way to resolve it.

Please help. Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions