Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 安卓WindowManager removeView异常行为_Java_Android - Fatal编程技术网

Java 安卓WindowManager removeView异常行为

Java 安卓WindowManager removeView异常行为,java,android,Java,Android,在我的应用程序中,我通过WindowManager添加 类型=WindowManager.LayoutParams.type\u系统\u警报 用户按下按钮后将其移除 windowManager.removeView(警报视图) 在我的HTC中,Nexus 4、Nexus 7程序逻辑工作正常,但在LG-P715中它工作不正常。当我调用windowManager.removeView(alertView)视图未被删除,仍停留在屏幕上,下一次调用windowManager.removeView(ale

在我的应用程序中,我通过WindowManager添加

类型=WindowManager.LayoutParams.type\u系统\u警报

用户按下按钮后将其移除

windowManager.removeView(警报视图)

在我的HTC中,Nexus 4、Nexus 7程序逻辑工作正常,但在LG-P715中它工作不正常。当我调用
windowManager.removeView(alertView)
视图未被删除,仍停留在屏幕上,下一次调用
windowManager.removeView(alertView)
时,我的应用程序因
IllegalArgumentException
而崩溃,这意味着已删除的视图。 我不明白发生了什么,我怎么能解决这个问题。 请帮忙,我需要你的建议

公共int onStartCommand(Intent Intent、int标志、int startId){


不是主页按钮,按钮放在视图上。你能提供源代码吗?请提供logcat为什么你需要logcat?我没有errors@NikedLab在
Service
onCreate()
中添加
视图
,并将其作为
onstart命令()删除
可以在每次调用
startService()
时多次调用。。。
    windowManager = (WindowManager) getApplicationContext().getSystemService("window");

    alertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.alert_screen, null);

    Button unlockButton = (Button) alertView.findViewById(R.id.hideButton);
    unlockButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            hide();
        }
    });

    param = new WindowManager.LayoutParams();
    param.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    param.height = ViewGroup.LayoutParams.FILL_PARENT;
    param.width  = ViewGroup.LayoutParams.FILL_PARENT;
    param.format = PixelFormat.RGBA_8888;
    param.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
    param.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
            WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
    windowManager.addView(alertView, param);

    return START_NOT_STICKY;
}

private void hide() {
    if (windowManager != null) {
        try {
            windowManager.removeView(alertView);
        } catch (IllegalArgumentException e) {
            Logger.e("IllegalArgumentException in detach window");
        }

        alertView = null;
    }
    stopSelf();
}