关于WindowManager的一个小问题was originally added here

原创 2015年11月19日 14:42:52


 WindowManager  :悬浮层   它的View显示在整个系统的最顶层,在设置属性后,此View则可以存在手机主窗口上


给windowManager添加overlay这个视图

LayoutInflater inflater = LayoutInflater.from(this);
overlay = (TextView) inflater.inflate(R.layout.overlay, null);
overlay.setVisibility(View.INVISIBLE);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
        LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
        WindowManager.LayoutParams.TYPE_APPLICATION,
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
        PixelFormat.TRANSLUCENT);
windowManager = (WindowManager)this.getSystemService(Context.WINDOW_SERVICE);
windowManager.addView(overlay, lp);

但是当我关闭此activity时会报如下错误:

   12801-12801/com.wjf.fw.mybus E/WindowManager﹕ Activity com.wjf.fw.mybus.ChangeCityActivity has leaked window android.support.v7.widget.AppCompatTextView{4279d760 I.ED.... ......I. 0,0-130,186} that was originally added here
    android.view.WindowLeaked: Activity com.wjf.fw.mybus.ChangeCityActivity has leaked window android.support.v7.widget.AppCompatTextView{4279d760 I.ED....


虽然此错误不影响应用使用,但毕竟是错误,应该去解决:当销毁activity时应去掉WindowManager的视图

@Override
protected void onDestroy() {
    super.onDestroy();
  windowManager.removeView(overlay);
}




版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

【已解决】Activity MainActivity has leaked window PhoneWindow$DecorView@ that was originally added here

今天写Sqlite Demo时,发生如下错误: Activity me.dengfengdecao.android.savedatademo.MainActivity has leaked ...

Activity has leaked window that was originally added

Activity has leaked window that was originally added 问题日志相信很多同学都遇到过这个问题window leak。 日志如下 E: androi...

Android排错:has leaked window com.android.internal.policy.impl.PhoneWindow$ that was originally added

异常场景:经常在应用中需要处理一些耗时的工作,诸如读取大文件、访问网络资源等。为了避免因程序假死而带来的糟糕用户体验,通常我们可以通过线程+Handler或者Android提供的AsyncTask来解...
  • gacmy
  • gacmy
  • 2016-09-24 10:35
  • 233

Activity has leaked IntentReceiver that was originally registered here. Are you missing a call to u

每次开机的时候应用都会停止运行一次,看log提示以下错误: 09-23 16:56:57.704: E/ActivityThread(938): Activity com.sckj.mo8_lau...

has leaked IntentReceiver ...that was originally registerd here.Are you missing a call to unregister

今天碰到了这个错误:has leaked IntentReceiver ...that was originally registerd here.Are you missing a call to ...

leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405241b0 that was originally ad

先贴异常: [java] view plain copy 05-05 10:36:41.009: E/WindowManager(4243): Ac...

access中的一个小问题

  • 2009-05-21 19:10
  • 31KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)