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 not shown in onEvent()

See original GitHub issue

Hi,

Just needed a quick way to show a Toast in an Activity if something in an other non-activity class fails. Found this librarie and used your How-To to quickly implement it.

This is virtually copy and pasted from your how to. but the Toast won’t show up even though the Log triggers. This Snippet is in my MainActivity. Toasts from other places in the code are working.

    @Override
    public void onStart() {
        super.onStart();
        EventBus.getDefault().register(this);
    }

    @Override
    public void onStop() {
        EventBus.getDefault().unregister(this);
        super.onStop();
    }

    public void onEvent(errorEvent event){
        Looper.prepare();
        Log.v("Error! onEvent : ", event.message);
        Toast.makeText(MainActivity.this, event.message, Toast.LENGTH_LONG).show();
    }

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
tilmanginzelcommented, Sep 20, 2016

Which EventBus version are you using? onEventMainThread was necessary in EventBus 2, but EventBus 3 uses annotations.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(AnyEventType event) {/* Do something */};
0reactions
Dreamystifycommented, Sep 19, 2016

Even with “onEventMainThread” I still get the issue with the need to call looper.prepare(); any ideas?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toast Message will not display if placed at the beggining of ...
I am having an issue with displaying a toast message. I want it to display when a button is initially clicked, so that...
Read more >
ShowToastEvent notification is not displayed in LWC
In your case the 3 part is not performed because there's no component listening to ShowToastEvent so the toast is not showed.
Read more >
Toasts - Bootstrap
Toasts. Push notifications to your visitors with a toast, a lightweight and easily customizable alert message. Toasts are lightweight notifications designed ...
Read more >
A cleaner way to interact between Composable and ...
So lets create the onEvent function in our viewmodel as follows ... makeText(context,"All inputs are valid", Toast.LENGTH_SHORT) .show() }
Read more >
Toast Notifications > Symfony UX: Turbo | SymfonyCasts
Let's fix that! Back in the controller, import Toast from bootstrap . Below add const toast = new Toast() and pass ...
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