I need to reproduce Application Not Responding (ANR) dialogs from Activity and from BroadCastReceiver. I tried to create a simple button click:
public void makeANRClick(View view){
while (true);
}
With this code I reproduced ANR on emulator with android 2.3.7. Same code doesn't work on real device with the newest android versions (4+).
Another attempt was as follows:
public void onMakeANRClick(View view){
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
This doesn't help also. Any suggestions?