Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This comment itself proves what should have be `context.isInFoteground()` function call has been made more complicated.



There isn't a single definition of what foreground means and typically usage of something like that would be a signal of poor design leading you to the point of wanting such a thing.


Toast can only be displayed when the app is the foreground.

If there is not single definition of what foreground is then how is someone supposed to know whether a toast will be displayed or not?


If someone wants to know the real definition they need to read the AOSP code. The code is the source of truth and it could potentially change in a future versions if a new security concern came in.

https://cs.android.com/android/platform/superproject/main/+/...

Whether a toast is successfully toasted is reported back to the app's process, but the android framework doesn't expose this result to the app which implies that one shouldn't need to rely on the toast being shown or not.


> which implies that one shouldn't need to rely on the toast being shown or not.

I wanted to display Toast if I can, and if not, a developer might prefer to display a Snackbar or a notification if a Toast cannot be displayed.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: