andrew
06/14/2023, 10:44 PMandrew
06/14/2023, 10:45 PMDavide Giuseppe Farella
06/17/2023, 9:18 AMtony-choi
06/30/2023, 7:25 AMRicardo Cardona
07/07/2023, 10:13 PMtony-choi
07/17/2023, 8:13 AMRohan Gupta Kandikonda
07/17/2023, 6:14 PMMarcel Pinto
07/18/2023, 5:27 AMDavide Giuseppe Farella
07/26/2023, 5:27 PMMario Andhika
07/27/2023, 9:20 AMRohan Gupta Kandikonda
07/28/2023, 7:58 PMheec.choi
08/25/2023, 12:58 AMJames O Claire
08/30/2023, 1:53 PMprivate val Context.datastore by dataStore(fileKey, WeatherInfoSerializer)
(replaceing the default FILENAME parameter with fileKey, but as it was not yet initialized, it does not work. I'm a bit lost as to how this should be done, though the comments in WeatherApp allude to it being close. Could someone share some help?
I also asked my question here in Stack Overflow:
https://stackoverflow.com/questions/77008645/how-to-make-unique-datastore-for-each-glance-widgetHamza GATTAL
09/01/2023, 5:59 PMSummers Pittman
09/06/2023, 5:29 PMJames O'Claire
09/13/2023, 2:10 PMPermission Denial: opening provider com.thirdgate.stormtracker.ImageFileProvider from ProcessRecord{2899a4f 1117:com.google.android.apps.nexuslauncher/u0a151} (pid=1117, uid=10151) that is not exported from UID 10185
followed by a second warning:
Error inflating RemoteViews android.widget.RemoteViews$ActionException: java.lang.SecurityException: Permission Denial: opening provider com.thirdgate.stormtracker.ImageFileProvider from ProcessRecord{2899a4f 1117:com.google.android.apps.nexuslauncher/u0a151} (pid=1117, uid=10151) that is not exported from UID 10185
I think the issue it is highlighting is that the original permission was granted to the first . This is done with essentially the same code as the above example:
// Find the current launcher every time to ensure it has read permissions
val intent = Intent(Intent.ACTION_MAIN).apply { addCategory(Intent.CATEGORY_HOME) }
val resolveInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.packageManager.resolveActivity(
intent,
PackageManager.ResolveInfoFlags.of(PackageManager.MATCH_DEFAULT_ONLY.toLong()),
)
} else {
@Suppress("DEPRECATION")
context.packageManager.resolveActivity(
intent,
PackageManager.MATCH_DEFAULT_ONLY,
)
}
val launcherName = resolveInfo?.activityInfo?.packageName
if (launcherName != null) {
context.grantUriPermission(
launcherName,
contentUri,
FLAG_GRANT_READ_URI_PERMISSION or FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
)
}
How should I store the images so that the URI permissions persist across reinstalls or restarts? Is there any other way I can test this situation? As I mentioned, the whole widget appears to die, but no error logs are shown for my app in logcat.James O'Claire
09/18/2023, 2:15 AMJames O'Claire
09/29/2023, 3:19 AMandroid:initialLayout="@layout/glance_widget_initial_layout
Finally, I realized what was causing this was the selection Run > Edit Configurations > "Always install with package manager (disables deploy optimizations on Android 11 and later".
This can be recreated in the JetNews example widget:
https://github.com/android/compose-samples/tree/ee198110d8a7575da281de9bd0f84e91970468ca/JetNews by selecting "Always install with package manager", adding JetNews to the home screen and pressing the 'Run App' a second time.
This selection is default to false, and I had been selecting it based on some earlier tutorials like this one about developing on Glance:
https://medium.com/androiddevelopers/demystifying-jetpack-glance-for-app-widgets-8fbc7041955c
https://proandroiddev.com/building-a-widget-using-jetpack-glance-59317dfbfe9
@Marcel Pinto Sorry to bother you, but just curious why you originally recommended this in your blog? I don't know what that option does, but it sounds like it installs it in a way closer to what would happen regularly for a user when the app is updated from Google Play?undermark5
10/02/2023, 11:36 PMLaunchedEffect
that manually updates the widget via update
but this is almost certainly definitely not how it is supposed to be done.Nat Strangerweather
10/30/2023, 5:25 PMNat Strangerweather
11/01/2023, 6:04 PMRow( modifier = GlanceModifier.fillMaxSize()){}
But that gives me a transparent background. If I add a background
modifier, I have to hardcode my color. My Buttons
in the Row
are Material You when I don't hardcode a color.orz
11/09/2023, 3:40 PMactionStartActivity
with an Intent
broken on Android 14? I’ve got the following set up:
...
val intent = Intent(
Intent.Action_VIEW,
widgetDeepLinkUrl.toUri(),
).apply {
putExtra("fromWidget", true)
}
...
modifier = GlanceModifier
.actionStartActivity(
intent = intent
)
...
The above works fine to deep link into the app in versions < 14. As a side note, I can get this to work on Android 14, if I use a custom ActionCallback
where I call context.startActivity(intent)
manually instead of just passing an Intent
.Ido Flax
12/15/2023, 5:45 PMIdo Flax
12/28/2023, 12:25 AMheec.choi
01/03/2024, 10:04 AMVinu Polly
01/31/2024, 3:29 PMJan Bína
02/10/2024, 2:49 PMTextStyle
is of type ColorProvider
and the factory function to create ColorProvider
from resource is restricted to the library and says
Returns a [ColorProvider] that resolves to the color resource. This should not be used outside of the Glance Libraries due to inconsistencies with regards to what process (app vs launcher) colors are resolved inThat's also the case with
colorFilter
for Image
, color of CircularProgressIndicator
and probably more.
On the other hand, there's a .background
modifier that accepts color resource and is working just fine.
I tried to overcome this by using RemoteViews
directly, so for example I can set the color of Text like this:
AndroidRemoteViews(
remoteViews = RemoteViews(context.packageName, R.layout.widget_textview).apply {
setTextViewText(R.id.text, text)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
setTextViewTextColorResource(R.id.text, colorRes)
} else {
setTextColor(R.id.text, LocalContext.current.getColor(colorRes))
}
},
)
and this seems to be working fine too. After all, the glance theme's dynamic colors are also created from resources...
So, what's the reason for that restriction of ColorProvider
? And can my approach with remote views cause troubles in some cases (not resolving to correct color)?Md Sohail
02/19/2024, 11:55 AMBirgit L
03/15/2024, 3:16 PMglance-experimental-tools
for getting a preview for your app widget? I've tried appwidget-host
as well as appwidget-viewer
but didn't have success with either method. Is this still the way to do glance previews or is there a newer method out there? My widget is done, so technically I don't need previews any more but I would have liked to use the preview image export.