Skip to content

Commit 4fe8837

Browse files
committed
fixed the issue: Init JUIWindow first before calling Toast fixed the issue
1 parent f56a942 commit 4fe8837

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

samples-android/ButtonClicker/jni/ButtonClickerNativeActivity.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,15 @@ void Engine::LeaveGame() {
561561
*/
562562
void Engine::InitUI() {
563563
// Show toast with app label
564+
565+
// The window initialization
566+
jui_helper::JUIWindow::Init(app_->activity, JUIHELPER_CLASS_NAME);
567+
564568
ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([]() {
569+
if(NULL == jui_helper::JUIWindow::GetInstance()->GetContext()) {
570+
LOGE("====JUIWindow::Context is NULL, not showing Toast");
571+
return;
572+
}
565573
jui_helper::JUIToast toast(
566574
ndk_helper::JNIHelper::GetInstance()->GetAppLabel());
567575
toast.Show();
@@ -573,7 +581,7 @@ void Engine::InitUI() {
573581
//
574582

575583
// The window initialization
576-
jui_helper::JUIWindow::Init(app_->activity, JUIHELPER_CLASS_NAME);
584+
// jui_helper::JUIWindow::Init(app_->activity, JUIHELPER_CLASS_NAME);
577585

578586
//
579587
// Buttons

0 commit comments

Comments
 (0)