Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: #48

Closed
2 tasks done
jscti opened this issue Jun 27, 2023 · 1 comment
Closed
2 tasks done

[Bug]: #48

jscti opened this issue Jun 27, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@jscti
Copy link

jscti commented Jun 27, 2023

Is there an existing issue for this?

  • I have searched the existing issues

In which area is the issue?

User Interface

In a specific sample?

appwidgets

What happened?

Hello there

I can't get a unique datastore per widget with Glance beta01. In your samples, there is a mention to it, but could you clarify how to inject the key in the datastore name ?

Question asked on SO (feel free to close this issue) : https://stackoverflow.com/questions/76563756/android-datastore-how-to-create-it-with-a-dynamic-filename/76564053

Thanks

From https://github.com/android/platform-samples/blob/main/samples/user-interface/appwidgets/src/main/java/com/example/platform/ui/appwidgets/glance/weather/WeatherInfoStateDefinition.kt :

/**
 * Use the same file name regardless of the widget instance to share data between them
 *
 * ====>>>>>If you need different state/data for each instance, create a store using the provided fileKey<<<<<<=====
 */
private val Context.datastore by dataStore(DATA_STORE_FILENAME, WeatherInfoSerializer)

override suspend fun getDataStore(
    context: Context,
    fileKey: String
): DataStore<SingleWidgetInfo> {
    return context.datastore // How to use fileKey while creating the datastore ?
}

Relevant logcat output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jscti jscti added the bug Something isn't working label Jun 27, 2023
@marcelpinto
Copy link
Contributor

With the new glance release the concept of glance state is no needed anymore you should use recomposition and/or standard storage patterns with data store, DB or others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants