Hi, we have implemented a widget with Glance that ...
# glance
o
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
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
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
388 Views