https://kotlinlang.org logo
#glance
Title
# glance
o

Odin

03/23/2022, 9:49 AM
Hi, we have implemented a widget with Glance that uses
actionRunCalback
with an action that uses a deeplink to open the app. We're doing this because our Glance widget is in a different module than our
MainActivity
and then to avoid
CircularDependencyException
. However, we're seeing a rather strange error from Crashlytics saying
java.lang.IllegalArgumentException: List adapter activity trampoline invoked without specifying target intent.
. I saw that there was a check in
ActionTrampoline.kt
that could throw this. Has anyone else seen this before? 😄 Stacktrace in thread 🧵
Copy code
Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.healthfitnessnordic.gxbooking/androidx.glance.appwidget.action.InvisibleActionTrampolineActivity}: java.lang.IllegalArgumentException: List adapter activity trampoline invoked without specifying target intent.
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
       at android.app.ActivityThread.-wrap12(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6124)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:890)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:780)

Caused by java.lang.IllegalArgumentException: List adapter activity trampoline invoked without specifying target intent.
       at androidx.glance.appwidget.action.ActionTrampolineKt.launchTrampolineAction(ActionTrampoline.kt:86)
       at androidx.glance.appwidget.action.InvisibleActionTrampolineActivity.onCreate(InvisibleActionTrampolineActivity.kt:31)
       at android.app.Activity.performCreate(Activity.java:6699)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727)
       at android.app.ActivityThread.-wrap12(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6124)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:890)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:780)
It happens on Android 7 but can't manage to reproduce it 🤔
p

Piotr Prus

03/24/2022, 6:55 AM
I didnt have this error, but I can give you a hint how I am dealing with opening the app from different module 🙂
Copy code
val appIntent = Intent(context, Class.forName("com.myname.android.main.MainActivity")).apply {
        addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
    }
than use it with `actionStartActivity`:
Copy code
.clickable(onClick = actionStartActivity(intent = appIntent))
Odin, could you paste the ActionCallback class that you use for deepLink? How you start the activity using deeplink?
o

Odin

04/08/2022, 6:55 AM
Hi, sorry for late reply. The
ActionCallback
class we use looks like this
Copy code
class OpenAppAction : ActionCallback {
    override suspend fun onRun(context: Context, glanceId: GlanceId, parameters: ActionParameters) {
        val intent = Intent(Intent.ACTION_VIEW, Uri.parse("deeplink")).apply {
            setPackage(context.packageName)
            flags = Intent.FLAG_ACTIVITY_NEW_TASK
        }
        context.startActivity(intent)
    }
}
We also use the
Copy code
onClick = actionStartActivity<Activity>(),
For opening different parts of the app that the module can depend on 😄
👍 1
297 Views