【发布时间】:2012-11-16 18:48:43
【问题描述】:
这是我添加视图的代码:
LayoutInflater layoutInflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
TextView tv = (TextView) layoutInflater.inflate(R.layout.textview, null);
final View view = tv;
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, 25,
WindowManager.LayoutParams.TYPE_STATUS_BAR,
WindowManager.LayoutParams.FLAG_SCALED
, PixelFormat.TRANSLUCENT);
WindowManager wm = (WindowManager) getApplicationContext().getSystemService(WINDOW_SERVICE);
wm.addView(view, lp);
但它会给我一个错误:
android.view.WindowManager$BadTokenException: 无法添加窗口 android.view.ViewRootImpl$W@41668948 -- 此窗口类型的权限被拒绝
所以我在 android manifast 中添加权限
<uses-permission android:name="android.permission.STATUS_BAR" />
但还是有错误,我需要帮助!!
【问题讨论】:
标签: android notifications statusbar