Yingding Wang
01/12/2023, 2:16 PMNavGraphBuilder.scrollable
, called the deepLink with a PendingIntent from complication, and got java.lang.IllegalArgumentException: The WearNavigator backstack is empty, there is no navigation destination to display.
Is this normal?Yingding Wang
01/12/2023, 2:22 PMjava.lang.IllegalArgumentException: The WearNavigator backstack is empty, there is no navigation destination to display.
My deep link intent:
val deepLinkIntent = Intent(
Intent.ACTION_VIEW,
DeepLinkHelper.historyLink.toUri(),
ctx,
HomeActivity::class.java, // there is navHost defined in HomeActivity
)
// adding the complication flag
// <https://stackoverflow.com/questions/2232238/how-to-bring-an-activity-to-foreground-top-of-stack/2235130#2235130>
deepLinkIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
My PendingIntent:
val deepLinkPendingIntent: PendingIntent? =
return TaskStackBuilder.create(ctx).run {
addNextIntentWithParentStack(intent)
getPendingIntent(requestCode, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
}
I also tried building PendingIntent with:
PendingIntent.getActivity(
ctx,
requestCode,
intent, // buildHistoryDeepLinkIntent(ctx),
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE // Immutable is necessary due to a security fix
)
and the same result, IllegalArgumentException: The WearNavigator backstack is empty
Yingding Wang
01/12/2023, 2:27 PMnavController
in the onCreate() of HomeActivity,
override fun onCreate(savedInstanceState: Bundle?) {
mAmbientCallback = HomeActivityAmbientCallback()
super.onCreate(savedInstanceState)
setContent {
WearAppTheme {
navController = rememberSwipeDismissableNavController()
WearApp(
navController = navController!!,
I noticed that navController is null while onResume() of the HomeActivity is called, it seems to me the composable code is called later then onResume() ? Any hints are really appreciated.stevebower
01/12/2023, 4:52 PMstevebower
01/12/2023, 4:54 PMYingding Wang
01/12/2023, 5:05 PM<activity
android:name=".ui.home.HomeActivity"
android:launchMode="singleInstance"
android:theme="@style/composeWearAppTheme"
android:label="@string/wear_menu_activity_label"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!-- implicit deeplink -->
<data android:scheme="https" android:host="www.example.com"/>
</intent-filter>
I used the NavGraphBuilder
from the horologist.WearNavScaffold
, but I don’t have a nav_graph.xml
The DeepLinkHelper.historyLink = "<http://www.example.com/my_route|www.example.com/my_route>"
Yingding Wang
01/12/2023, 5:11 PMNavGraphBuilder
code is
WearNavScaffold(
…
builder = {
scrollable(
route = "my_route",
deepLinks = listOf(navDeepLink {
uriPattern = "<http://www.example.com/my_route|www.example.com/my_route>" })
) { ... }
})
Yingding Wang
01/12/2023, 5:38 PMandroidx.wear.compose.navigation.NavGraphBuilder
, but with com.google.android.horologist.compose.navscaffold.NavGraphBuilder
from`horologist` . Could this be the issue? Where can i found out which Navigator i have imported?stevebower
01/12/2023, 5:55 PMYingding Wang
01/12/2023, 6:04 PMYingding Wang
01/12/2023, 6:10 PMuriPattern
, <http://www.example.com/my_route|www.example.com/my_route>
doesn’t work, but <http://www.example.com|www.example.com>
works.
deepLinks = listOf(navDeepLink {
uriPattern = "<http://www.example.com/my_route|www.example.com/my_route>" })
But why it is the case, how can i define multiple deep links with the same host <http://www.example.com|www.example.com>
Yingding Wang
01/12/2023, 6:34 PMandroid:launchMode="singleInstance"
thus the deepLinks with subpath uriPattern
“www.example.com/my_route”, doesn’t work.
I added navController.handleDeepLink(intent)
to my activity
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
navController.handleDeepLink(intent)
}
now it works.
Referen: https://stackoverflow.com/questions/69781886/deep-links-navigation-in-jetpack-compose/70276252#70276252
We shall document this also on the wear navi doc, if it is the root cause. Can any of you double check my assumption. Thanks in advance.stevebower
01/12/2023, 9:18 PM<http://www.example.com/my_route|www.example.com/my_route>
so I think you've found the answer.yschimke
01/12/2023, 11:20 PMYingding Wang
01/13/2023, 12:39 AMyschimke
01/13/2023, 12:39 AMYingding Wang
01/13/2023, 1:27 AMWearNavScaffold/scrollable
very much 🙂 A couple of things I noticed:
• The timeTextMode, positionIndicatorMode, etc in ScrollableScaffoldContext is really great, it makes more fun to build app.
• While using the default autoCentering itemIndex=1, for AnimatedVisibility(visible = expanded)
sometimes the time text in WearNavScaffold/scrollable
jumps a little bit.
Overall, WearNavScaffold is really a bless, thanks for making it.yschimke
01/13/2023, 1:28 AMWhile using the default autoCentering itemIndex=1, for two items in SLC, the first items can be very close to the time text.Is it text or a Chip?
Yingding Wang
01/13/2023, 1:29 AMIs it text or a Chip?Text, I add sometimes an empty item without spacer, things goes better.
yschimke
01/13/2023, 1:30 AMyschimke
01/13/2023, 1:30 AMscrollable
, rightYingding Wang
01/13/2023, 1:30 AMyschimke
01/13/2023, 1:31 AMYingding Wang
01/13/2023, 1:31 AMyschimke
01/13/2023, 1:32 AMYingding Wang
01/13/2023, 1:32 AMyschimke
01/13/2023, 1:35 AMautoCentering itemIndex=1, for two items in SLCthe
scrollable
fun has a param defaulted to ScalingLazyColumnDefaults.belowTimeText()
that stops is using itemIndex=1, offset = 0, you end up with itemIndex = 0 and offset = screenHeightPx / 2 - topPaddingPx
Yingding Wang
01/13/2023, 1:40 AMyschimke
01/13/2023, 1:41 AMYingding Wang
01/13/2023, 1:41 AMyschimke
01/13/2023, 1:42 AMYingding Wang
01/13/2023, 1:42 AMyschimke
01/13/2023, 1:43 AMScalingLazyColumnDefaults.belowTimeText(firstItemIsFullWidth = true)
John Nichol
01/13/2023, 8:07 AMModifier.scrollAway()
,ScalingLazyListState
and/or AutoCentering
inconsistentyschimke
01/13/2023, 8:08 AMJohn Nichol
01/13/2023, 8:09 AMScalingLazyColumn
then it looks like the the normal horizontal padding has been overriddenYingding Wang
01/13/2023, 9:14 AMcontentPadding
in SLC
contentPadding = PaddingValues(horizontal = 6.dp), // to make less padding
Yingding Wang
01/13/2023, 11:26 AMyschimke
01/13/2023, 11:27 AMyschimke
01/16/2023, 5:43 PMyschimke
01/16/2023, 5:43 PMyschimke
01/16/2023, 5:43 PMYingding Wang
01/16/2023, 9:54 PMcolumnStateFactory
as you have already posted. Sorry for that. 🙂
https://kotlinlang.slack.com/archives/C02GBABJUAF/p1672277001696559?thread_ts=1672146428.263589&cid=C02GBABJUAFYingding Wang
01/18/2023, 4:31 PMyschimke
01/18/2023, 4:48 PMyschimke
01/18/2023, 4:49 PMyschimke
01/18/2023, 4:49 PMyschimke
04/11/2023, 8:12 AMYingding Wang
04/11/2023, 10:07 AMandroid:launchMode="singleInstance"
is set for your activity, and does adding onNewIntent to trigger navController.handleDeepLink
manually works for you?
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
navController.handleDeepLink(intent)
}
Update: this also happens, as i call the startActivity() with FLAG_ACTIVITY_SINGLE_TOP , if the activity is already created. It will not trigger the navController.handleDeepLink
.yschimke
04/28/2023, 7:24 AMyschimke
05/02/2023, 6:34 PM