MiguelSlv
MiguelSlv

Reputation: 15113

Error receiving broadcast Intent { act=com.google.android.gms.appinvite.intent.action.INVITE_SENT

I am getting this error on a physical device (Samsung SM-J710F) running Android API 27. The same code works well on a physical device running API 21.

I use this Kotlin code from Firebase documentation to test:

private fun onClick() {
    val intent = AppInviteInvitation.IntentBuilder("Title test")
            .setMessage("Invite Test")
            .setCallToActionText("call back test")
            .build()
    startActivityForResult(intent, REQUEST_INVITE)
}

 override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    Log.d(TAG, "onActivityResult: requestCode=$requestCode, resultCode=$resultCode")

    if (requestCode == REQUEST_INVITE) {
        if (resultCode == Activity.RESULT_OK) {
            // Get the invitation IDs of all sent messages
            val ids = AppInviteInvitation.getInvitationIds(resultCode, data!!)
            for (id in ids) {
                Log.d(TAG, "onActivityResult: sent invitation $id")
            }
        } else {
          //resultCode is always Activity.RESULT_CANCELED (0)
        }
    }
}

Gradle:

implementation 'com.google.firebase:firebase-invites:16.0.6'

The email is send but the activity result returns:

  1. resultCode is always Activity.RESULT_CANCELED (0)
  2. data is always null

I find this answer for a similar post, saying this particular error can occur on Android 8 devices.

Here the full stack:

 java.lang.RuntimeException: Error receiving broadcast Intent { act=com.google.android.gms.appinvite.intent.action.INVITE_SENT cat=[android.intent.category.DEFAULT] flg=0x10 (has extras) } in com.google.android.gms.appinvite.AppInviteChimeraActivity$AppInviteResponseReceiver@ea2626
        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_54380(LoadedApk.java:1365)
        at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.$m$7(Unknown Source:4)
        at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.run(Unknown Source:39)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:7000)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
     Caused by: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@abaa43e -- permission denied for window type 2003
        at android.view.ViewRootImpl.setView(ViewRootImpl.java:1026)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:384)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:101)
        at gkf.a(:com.google.android.gms@[email protected] (040306-223214910):23)
        at gkf.a(:com.google.android.gms@[email protected] (040306-223214910):15)
        at gkf.a(:com.google.android.gms@[email protected] (040306-223214910):1)
        at com.google.android.gms.appinvite.AppInviteChimeraActivity.a(:com.google.android.gms@[email protected] (040306-223214910):107)
        at com.google.android.gms.appinvite.AppInviteChimeraActivity$AppInviteResponseReceiver.a(:com.google.android.gms@[email protected] (040306-223214910):2)
        at ygn.onReceive(:com.google.android.gms@[email protected] (040306-223214910):1)
        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_54380(LoadedApk.java:1355)
        at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.$m$7(Unknown Source:4) 
        at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.run(Unknown Source:39) 
        at android.os.Handler.handleCallback(Handler.java:790) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:7000) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

Looking at the stack, it seams the original problem is permissions:

 Unable to add window android.view.ViewRootImpl$W@abaa43e -- permission denied for window type 2003 

By the this same answer, would need to change how Firebase request permissions, what i can't do. I am stuck here.

Update: I try with Firebase quickstart invites project and got the same behavior:

I still think it must be something i miss look, because it is not much plausible that even the simplest test fails.

Upvotes: 1

Views: 1637

Answers (1)

dev.for.fun
dev.for.fun

Reputation: 1240

One thing to consider is that Firebase Invites has been deprecated. Firebase recommends the use of Dynamic Links moving forward.

Upvotes: 1

Related Questions