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.

Improve Android alert/prompt behaviour?

See original GitHub issue

Looks like using window.prompt or window.alert ends up with extremely ugly alerts. Example (local html):

image

Is it possible to improve this? Afer doing some research, seems like it can be improved by using the Chrome client, something like…

webView.setWebChromeClient(new WebChromeClient() {

    @Override
    public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
        AlertDialog dialog = new AlertDialog.Builder(view.getContext()).
                setTitle("YourAlertTitle").
                setMessage(message).
                setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //do nothing
                    }
                }).create();
        dialog.show();
        result.confirm();
        return true;
    } });

Further looking at the code, this library is already using the chrome client, so perhaps it is straight forward to implement:

https://github.com/react-native-community/react-native-webview/blob/master/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java#L706

https://github.com/react-native-community/react-native-webview/blob/master/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java#L717

So it would be a matter of implementing: image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
cristianoccazinspcommented, Jul 22, 2020

Wow, 2 months already, time flies! Can we re-open this? This is definitely still an issue. Alert/Prompts are all nicely implement on iOS, while they look terrible on Android!

0reactions
NTKriegercommented, Jul 6, 2021

I would like to report that it’s July 2021 and Alert.alert() on Android is still too ugly for any commercial application kthx

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improve Android alert/prompt behaviour? · Issue #1385 - GitHub
Looks like using window.prompt or window.alert ends up with extremely ugly alerts. Example (local html): Is it possible to improve this?
Read more >
Notifications Overview | Android Developers
A notification is a message that Android displays outside your app's UI to provide the user with reminders, communication from other people, or...
Read more >
Behavior changes: Apps targeting Android 12
If your app targets Android 12, you must specify the mutability of each PendingIntent object that your app creates. This additional requirement improves...
Read more >
Create a Notification - Android Developers
Notifications provide short, timely information about events in your app while it's not in use. This page teaches you how to create a...
Read more >
Dialogs - Android Developers
Building an Alert Dialog ... The AlertDialog class allows you to build a variety of dialog designs and is often the only dialog...
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