question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Toast inside WeakReferenceMessenger event throws NULL

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I´m trying to use a toast message inside a Handler for a weakreferencemessenger in my BaseViewModel. Calling await toast.Show results in a Null reference exception. I also tried to call it inside a Dispatch - same result.

Expected Behavior

the toast should be shown. Outside of a weakreferencemessenger callback it works without any problem.

Steps To Reproduce

Create a waekreference event. Create a handler for that event. Call toast inside the event.

Link to public reproduction project repository

Environment

- .NET MAUI CommunityToolkit: latest (8.0)
- OS: Android (11+)
- .NET MAUI: .net 7

Anything else?

No response

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
VladislavAntonyukcommented, Nov 28, 2022

Toast is ui component, so it must be executed on ui thread: Can’t toast on a thread that has not called Looper.prepare()

0reactions
FM1973commented, Nov 28, 2022

Jup, when I call it on the main thread, everything works. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toast in Android fragments showing null pointer expn
I am getting errors on few devices where I am trying to display a toast inside fragments. this toast is usually on retrofit...
Read more >
Feed
This method checks if the event's sender is an instance of the ... the publishing can throw an error because inner frameworks and...
Read more >
Dotnet Maui Net Maui 7.0 | PDF | Hyper V | Xamarin
You can't run a VM-accelerated emulator inside another VM, ... Invoking an unregistered event, with the InvokeEvents method, doesn't throw an. exception.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found