WindowManager.addView() 崩溃

WindowManager.addView() crashes

这是我的代码:

protected window_fly (Context context) {

    WindowManager.LayoutParams params = new WindowManager.LayoutParams (
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
            PixelFormat.TRANSLUCENT ) ;

    params.gravity = Gravity.LEFT | Gravity.BOTTOM ;

    LayoutInflater layOutInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE)  ;
    View in_view = layOutInflater.inflate(R.layout.in_layout, null) ;
    Toast.makeText(context, "daemon born", Toast.LENGTH_SHORT).show() ; 
    WindowManager wm = (WindowManager) context.getSystemService(context.WINDOW_SERVICE); 
    //wm.addView(in_view, params);
}

全部在服务上下文中。 window_fly 是构造函数。如果我取消注释 wm.addView() 和 运行 它,应用程序将会下降。请告诉我可能的原因。抱歉英语不好。

已添加到包含 SYSTEM_ALERT_WINDOW 权限描述的清单行:

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>