Android Toast Message Is Not Showing

Android Toast Message is not showing

I did like this

Toast.makeText(SalesActivityGroup.group.getParent(), "Amount can not be 
grater than invoice", Toast.LENGTH_SHORT).show();

Toast.show() not showing the message in Emulator

Didn't know this could be done, but wiping data and cold-booting the device fixed it.

toast message does not show up

it was something wrong with my emulator...
if you have the same problem you should try another device.

Android Toast not showing up

It seems there was a problem with the app.
I solved it by deleting the app from the phone and reinstalling.

I can now show toasts using:

Toast.makeText(getApplicationContext(), "Test string", Toast.LENGTH_SHORT).show();

Android Toast doesn't show up

Go to your app settings -> Notifications and check if notifications are turned on. This action is possible in newer android versions

Even though a Toast is not a notification, it seems that NotificationManagerService.java will not show Toast if Notifications are disabled.

I'm posting a link with the issue:
https://issuetracker.google.com/issues/36951147

Toast message does not show up when I call it from app.components.ts

async functions return promises and should return something to the calling function

...
this.presentToast(data.message);
...

does neither

so you have 2 options:

  1. modify the presentToast function like so:

      presentToast(msg) {
    const toast = this.toast.create({
    message: msg,
    duration: 3000,
    position: 'top'
    });
    toast.present();

    }

  2. consume the returned promise and present the toast function in the calling function

    ...
initializeApp() {
...
this.presentToast(data.message).then(data =>
console.log('toast displayed')).catch(error =>
console.log(error));
...

async presentToast(msg) {
this.toast.create({
message: msg,
duration: 3000,
position: 'top'
});
return await toast.present();
}



Related Topics



Leave a reply



Submit