Adding text field to an alert box on Android with no contents causes a crash

Hi, fine on other OSes.

auto *p_alert = new AlertWindow( "Trial License", "Please enter your email address", AlertWindow::AlertIconType::NoIcon );
p_alert->addTextEditor( "email", "" );
p_alert->enterModalState( true, ModalCallbackFunction::create( [ = ]( int res ) {

Causes a crash. Changing the email default to “x” or any other string is fine.

Cheers

I don’t know why this is happening, it’s really strange. However for the time being you can either make your AlertWindow a member variable and do the addTextEditor() setup in its parent’s constructor and then call enterModalState() later or you can add a small delay between addTextEditor() and enterModalState() which oddly makes the crash disappear. Something like this:

auto *p_alert = new AlertWindow( "Trial License", "Please enter your email address", AlertWindow::AlertIconType::NoIcon );
p_alert->addTextEditor( "email", "" );

Timer::callAfterDelay (100, [=] { p_alert->enterModalState (true, ModalCallbackFunction::create ([=](int) { })); });

I have no idea why this is working though, I’ll try to dig into this a bit more.

2 Likes

Year late. this still exists. really strange.

Here is the ambiguous crashlog hoping it’ll improve the searchability of this thread for others.

CallIntMethodV called with pending exception java.lang.SecurityException: Using null token requires permission android.permission.WRITE_SECURE_SETTINGS
2020-02-01 23:05:47.070 10329-10329/com.talaviram.tick A/art: art/runtime/java_vm_ext.cc:470]   at void android.os.Parcel.readException(int, java.lang.String) (Parcel.java:1684)
2020-02-01 23:05:47.070 10329-10329/com.talaviram.tick A/art: art/runtime/java_vm_ext.cc:470]   at void android.os.Parcel.readException() (Parcel.java:1637)
2020-02-01 23:05:47.070 10329-10329/com.talaviram.tick A/art: art/runtime/java_vm_ext.cc:470]   at void com.android.internal.view.IInputMethodManager$Stub$Proxy.setInputMethod(android.os.IBinder, java.lang.String) (IInputMethodManager.java:763)
2020-02-01 23:05:47.070 10329-10329/com.talaviram.tick A/art: art/runtime/java_vm_ext.cc:470]   at void android.view.inputmethod.InputMethodManager.setInputMethod(android.os.IBinder, java.lang.String) (InputMethodManager.java:1759)
2020-02-01 23:05:47.070 10329-10329/com.talaviram.tick A/art: art/runtime/java_vm_ext.cc:470]   at void com.roli.juce.ComponentPeerView.showKeyboard(java.lang.String) (ComponentPeerView.java:212)