Android - Forcing ANR for testing purpose

后端 未结 6 1118
花落未央
花落未央 2020-12-16 03:42

Why i can\'t force Android ANR with this code? No log messages or pop up. The application is just launched lazily.

[UPDATE]

I can\'t get it even sleeping a V

6条回答
  •  眼角桃花
    2020-12-16 04:42

    I used this code for force ANR

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
    
        public void force(View view){
            while(true) {}
        }
    

    I just created a simple button in the xml file and set android:onClick=force

提交回复
热议问题