最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

flutter - Keep same data available in a Android app when openmaximised and minimised - Stack Overflow

matteradmin8PV0评论

I have written a very simple Dart/Flutter app for Android which can receive FireBase notifications both when the app is open and also when it is minimised. The problem is that I would like to save the data that have been send as a notification when the app is minimised and it would be shown in the app when it is maximised again. So far what I can tell when running the emulator is that the app has two different memory areas allocated, one when the app is opened/maximised and the other when the app is minimised (in the background).

How can I allocate a variable/memory that is common for the app when it is minimised and is open? Or maybe I need some kind of message service to send data over to the maximised app when it is minimised?

Thanks for have reading this

When running the Android emulator I can confirm that different memory is allocated when minimised and maximised.

I have written a very simple Dart/Flutter app for Android which can receive FireBase notifications both when the app is open and also when it is minimised. The problem is that I would like to save the data that have been send as a notification when the app is minimised and it would be shown in the app when it is maximised again. So far what I can tell when running the emulator is that the app has two different memory areas allocated, one when the app is opened/maximised and the other when the app is minimised (in the background).

How can I allocate a variable/memory that is common for the app when it is minimised and is open? Or maybe I need some kind of message service to send data over to the maximised app when it is minimised?

Thanks for have reading this

When running the Android emulator I can confirm that different memory is allocated when minimised and maximised.

Share Improve this question asked Nov 16, 2024 at 16:33 Assar WestmanAssar Westman 91 silver badge1 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

When the app isn't foreground, it can be killed for resources at any time. So if you want to do this, you can't use a variable. You have to persist it to disk- a database, a file, a shared preference, a data store, etc. But if it's just in memory, it may not be there when you want it in the future.

Post a comment

comment list (0)

  1. No comments so far