Comments (13)
Would love to see this merged :)
from toast-phonegap-plugin.
The solution @dpa99c works.
Add this changes
dpa99c@7a61201
and
I need to add the condition (if (Build.VERSION.SDK_INT >= 30) {) to work api less 30
if (Build.VERSION.SDK_INT >= 30) {
toast.addCallback(new android.widget.Toast.Callback() {
public void onToastShown() {
}
public void onToastHidden() {
returnTapEvent("hide", msg, data, callbackContext);
}
});
}
tested = api 31, 30 ,29, 28, 27 ... 23
from toast-phonegap-plugin.
Oh dear! Happy to merge a PR (I might have missed one?)
from toast-phonegap-plugin.
I am with problem with the plugin. It close my apps after display the message. What is the solution? Just in devices using android 11.
from toast-phonegap-plugin.
Toast.getView()
returns null on API Level 30+. As a temporary workaround, it's possible to add null checks before any calls that expect Toast.getView to return a View object. This styling block in Toast.java relies on the custom Toast View. To prevent crashes, it's possible to add a check that will exclude the block from running on API 30+, eg:
Toast.java
if (styling != null && Build.VERSION.SDK_INT >= 16 && Build.VERSION.SDK_INT < 30) { ... }
This is a temporary fix to prevent crashing, though it prevents styling from being applied to toasts on Android 11+.
@EddyVerbruggen what is the recommended approach for styling toasts going forward? The Toast docs mention using Snackbar— is this something you think would be within the scope of this plugin? This seems like an important issue to resolve since Android 11 is gaining marketshare quickly.
from toast-phonegap-plugin.
I got the same issue for my users, Crashlytics reports a lot of crashes recently because of this:
@EddyVerbruggen I think this is critical
from toast-phonegap-plugin.
@drewrygh there is other lines Here too https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/blob/master/src/android/nl/xservices/plugins/Toast.java#L163
from toast-phonegap-plugin.
@EddyVerbruggen what do you think about a new version of this plugin?
from toast-phonegap-plugin.
Is there a workaround for this? I don't need any styling, but just calling showShortBottom
is making my app crash once I touch on the screen after a toast.
E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.view.View.isShown()' on a null object reference
from toast-phonegap-plugin.
@zommerfelds at this point, I think the only workaround for this is just giving up Cordova and go flutter, Cordova is dying
Anyways, seriously, I think the only way now is just to fork and solve the issue and install the plugin from your repo, you can merge any PR you want as these PRs are already sent.
from toast-phonegap-plugin.
@zommerfelds We just started to show the toast alerts with javascript instead of through cordova for Android. There are many toast like javascript packages on npm, but it is also fairly simple to create your own.
@almothafar I'm also following flutter, but since it cannot be (reliably) used on the web I see it as a different tool, not perse a substitute for Cordova/ionic. But that's a different discussion ;)
from toast-phonegap-plugin.
@gabn88 I'm using Ionic toast as well https://ionicframework.com/docs/api/toast instead of native toast, I removed the native one from my side because of this issue.
from toast-phonegap-plugin.
Would be great to update the plugin for Android 11
from toast-phonegap-plugin.
Related Issues (20)
- duration does not seem to accept values on "show" and "showWithOptions"methods (Android 8.0) HOT 17
- Android P doesnt display toast HOT 2
- Toast not shown in Honor 8XS HOT 14
- Toast is not showing in Android 9.0.0 (OnePlus 5) HOT 5
- Toast deprecation error on iOS 12.1.2 HOT 1
- why does the message have my app name before it pops up and how to remove it?
- What are advantages over web popover?
- iOS - Toast is displayed full width, no margins on left or right
- How can I increase the width and height of the toast?
- Android 9.0 Toast are not showing 2nd time HOT 1
- How is it possible to read Toast text?
- styling verticalPadding is not working properly in Android OS version 10 HOT 1
- Test0123
- window.plugins.toast.showWithOptions is not working
- Position of notification in Android 11 HOT 1
- Crash from API 30 HOT 7
- On Toast Click not working
- `showShortTop()` method is showing toast at the bottom only not at the top
- No color or styling For Android 12 and 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from toast-phonegap-plugin.