`
mfan
  • 浏览: 338717 次
  • 性别: Icon_minigender_1
  • 来自: 南宁
社区版块
存档分类
最新评论

Dialog 出现的android.view.WindowManager$BadTokenException: Unable to add window异常

 
阅读更多

Dialog异常:
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

异常原因:
new AlertDialog.Builder(Context context)中的参数不能用getApplicationContext()获得的context,而必须使用Activity,因为只有一个Activity才能添加一个窗体。

解决办法:
例如 new AlertDialog.Builder(XXXActivity.this)

 

分享到:
评论

相关推荐

    android dialog与popwindow之间的简单运用

    注意:PopupWindow组件的使用问题,PopupWindow是一个阻塞对话框,如果你直接在Activity创建的方法中显示它,则会报错:android.view.WindowManager$BadTokenException:Unable to add window -- token null is not ...

    Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:29.+ *****

    版本错误的处理Install Repository and sync project show in file Show in Project Structure dialog

    Android 中 android.view.WindowLeaked的解决办法

    Android 中 android.view.WindowLeaked的解决办法 按字面了解,Window Leaked大概就是说一个窗体泄漏了,也就是我们常说的内存泄漏,为什么窗体会泄漏呢? 产生原因: 我们知道Android的每一个Activity都有个...

    WindowManager属性详解

    WindowManager属性详解:WindowManager.LayoutParams 是 WindowManager 接口的嵌套类;继承于 ViewGroup.LayoutParams 。 它的内容十分丰富。其实WindowManager.java的主要内容就是由这个类定义构成。

    EurekaLog_7.5.0.0_Enterprise

    8)....Added: Exception line highlighting in disassember view in EurekaLog exception dialog and Viewer 9)....Added: Detection/logging Delphi objects in disassembly view 10)..Added: Support for multi-...

    Dialog总结android.pdf

    Dialog总结android.pdf

    Android代码-FancyAlertDialog-Android

    Add this to your module's build.gradle file (make sure the version matches the JitPack badge above): dependencies { ... compile 'com.github.Shashank02051997:FancyAlertDialog-Android:0.1' } ...

    Android代码-DialogUtils

     Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories: allprojects { repositories { ... maven { url "https://jitpack.io" } } } S

    LDialog:android万能Dialog,定制属于你自己的对话框,学习成本低

    #使用详情: : //项目根目录下 build.gradle allprojects { repositories { ...LDialog dialog = LDialog.newInstance(this, R.layout.dialog_confirm); dialog .setMaskValue(0.5f) //遮罩--透明度

    android安卓app已经放弃使用Theme.Dialog,改用Theme.Holo.DialogWhenLarge

    android安卓app已经放弃使用Theme.Dialog,改用Theme.Holo.DialogWhenLarge

    F7Dialog.min.js

    F7Dialog.min.js ①设置DIV <div class="selectDepart" id="showBlockDiv" style="display:none;"> <em class="D_close" style="display: none;">X 加载中。。。</h2> ②开:Dialog({id:'showBlockDiv', lock...

    Android代码-FancyGifDialog-Android

    Add this to your module's build.gradle file (make sure the version matches the JitPack badge above): dependencies { ... compile 'com.github.Shashank02051997:FancyGifDialog-Android:1.1' } ...

    jQuery弹出层插件大全

    4.jQueryUI Dialog 官方网站:http://jqueryui.com/demos/dialog/ 下载地址:http://jqueryui.com/demos/dialog/ 演示实例:http://jqueryui.com/demos/dialog/ 5.DOM window 官方网站:...

    Android代码-Android 双层级 Dialog 选择框。

    Two Step Picker Dialog For Android Description Two step picker dialog for Android that helps you easily pick nested data on android. Usage To use two step picker dialog you must add it as a ...

    Sublime.Text.Build.3069._Win_32bit 破解版

    API: Added Window.extract_variables() API: Added Sheet.view() Build 3067 Release Date: 30 January 2015 Right clicking on a URL will show an 'Open URL' menu item Improved Console Panel scrolling ...

    Android代码-CBDialog

    集成了sweet-alert-dialog 集成了Titanic的进度框动画样式 集成了AVLoadingIndicatorView的动画样式 How To Useage 引入依赖 step1.Add it in your root build.gradle at the end of repositories: allprojects ...

    dwz.dialog.js

    打开时修改为以下内容 if (op.mask) { //修改所有对话框zIndex,900为覆盖层,要显示的对话框大于900,不显示的小于900 ... if ($(dialog).data("id")) $.taskBar.closeDialog($(dialog).data("id")); }

    Android代码-Material Design风格Preference UI

    //implementation 'moe.shizuku.preference:preference-dialog-appcompat:' // if you want to use appcompat version dialog //implementation 'moe.shizuku.preference:preference-switchcompat:' // appcompat v

    安卓Dialog对话框相关-项目通用Dialog.rar

    项目通用Dialog.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。

    Android代码-fogger

    You can blur view behind drawer, dialog window and context menu. How to get it Grab via Maven: pl.allegro.android fogger 0.9.0 aar or Gradle: compile 'pl.allegro.android:fogger:0.9.0' ...

Global site tag (gtag.js) - Google Analytics