React Native: alert : tried to show an alert while not attached to an activity
来源:互联网 发布:unity3d guitexture 编辑:程序博客网 时间:2024/06/01 08:08
今天使用alert来弹出消息时候,发现下方一直弹出一个黄色的错误提示:tried to show an alert while not attached to an activity,使用的是Android 4.x的机子。
经谷歌,发现是因为android->app->src->main->java下的MainActivity少了几个方法,将其补上就可以正常弹出Alert。另外尽量使用Alert.alert()来弹出alert(要先import Alert):
@Overrideprotected void onPause() { super.onPause(); if (mReactInstanceManager != null) { mReactInstanceManager.onHostPause(this); }}@Overrideprotected void onResume() { super.onResume(); if (mReactInstanceManager != null) { mReactInstanceManager.onHostResume(this, this); }}@Overrideprotected void onDestroy() { super.onDestroy(); if (mReactInstanceManager != null) { mReactInstanceManager.onHostDestroy(); }}@Override public void onBackPressed() { if (mReactInstanceManager != null) { mReactInstanceManager.onBackPressed(); } else { super.onBackPressed(); }}
阅读全文
0 0
- React Native: alert : tried to show an alert while not attached to an activity
- 解决React-Native-Attached-DialogModule-to-host-with-pending-alert-but-no-FragmentManager
- not attached to activity
- Fragment not attached to Activity
- Fragment not attached to Activity
- Fragment not attached to Activity
- Fragment not attached to Activity
- Fragment not attached to Activity
- fragment not attached to Activity
- react-native-Alert
- React Native 之Alert
- react-native-modal-alert
- react-native Alert组件
- qpage.alert - send an alert via QuickPage
- Fragment not attached to Activity 异常
- 关于Fragment not attached to Activity 异常
- Android - Fragment StepCounterStaticFragment not attached to Activity
- Fragment MyFragment not attached to Activity
- python中使用input函数时,为什么得到的返回值不能判断是否在列表里?
- angularjs模式
- Log4j的AsyncAppender能否提升性能?什么场景用比较好?
- Thymeleaf嵌套循环,每次循环显示固定数量
- The file name must end with .xml or .png
- React Native: alert : tried to show an alert while not attached to an activity
- momgo查询,使用临时变量判断
- 单向链表的创建和遍历
- PHP中文乱码解决办法
- [Linux C编程]多线程
- 什么是DSL
- 收藏的博客 -- 高性能Linux服务器
- leetcode--Count Complete Tree Nodes
- 图片保存到数据库blob字段