这是什么4行渣华code意味着Android应用程序? [英] What does this 4 line java code means in android application?
问题描述
在我的Java应用程序中,我有这个code
@覆盖
公共无效onAttachedToWindow()
{
。this.getWindow()的setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
super.onAttachedToWindow();
}
当我建立它的的Android 2.3(10级)编译和工作正常。但是,当我建立它的的Android 4.0(等级15)它编译并给我崩溃在运行时以下错误
07-16 14:00:03.090:E / AndroidRuntime(29487):致命异常:主要
07-16 14:00:03.090:E / AndroidRuntime(29487):java.lang.IllegalArgumentException:如果窗口被加入后窗口类型不能改变。
在我评论这条线,并建立它工作正常,并没有任何问题。
// this.getWindow()的setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
所以我没有得到为什么这happning和最新此code手段?
编辑: 一些参考的位置
<一个href="http://stackoverflow.com/questions/11498938/when-i-run-app-on-my-phone-the-version-is-android-4-0-3#comment16888792_11498938">when我对我的phone.The版本上运行的应用程序的是Android 4.0.3
<一个href="http://stackoverflow.com/questions/8072866/toddler-safe-app-on-android#comment16888776_8072866">toddler在Android 安全应用
@覆盖
公共无效onAttachedToWindow()
{
。this.getWindow()的setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
super.onAttachedToWindow();
}
用于停用home键的机器人,但
本安全漏洞已被固定在较新版本的Android ,这样就不会在ICS和果冻豆的工作... !!
In my java application i have this code
@Override
public void onAttachedToWindow()
{
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
super.onAttachedToWindow();
}
when i build it for android 2.3 (level 10) it compiles and works fine. But when i build it for android 4.0 (level 15) it compiles and gives me crash at run time and following error
07-16 14:00:03.090: E/AndroidRuntime(29487): FATAL EXCEPTION: main
07-16 14:00:03.090: E/AndroidRuntime(29487): java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
when i comment this line and build it works fine and no issue..
//this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
so i am not getting why this happning and whats this code means?
Edit : some reference are here
when I run app on my phone.The version is android 4.0.3
@Override
public void onAttachedToWindow()
{
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
super.onAttachedToWindow();
}
is used to disable home button in android but
this security flaw has been fixed in newer versions of Android so it will not work in ICS and jelly bean...!!
这篇关于这是什么4行渣华code意味着Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!