Android - Forcing ANR for testing purpose
android, android-anr-dialog
Solution
Try it in onTouchEvent. In onCreate your activity is not fully running
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.d(TAG,"onTouchEvent");
while(true) {}
}
Problem
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 View.setOnClickListener or BroadcastReceiver.onReceive! Is there a trick? ``` public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try { Thread.sleep(10000); } catch (InterruptedException e) { Log.e("Test", "", e); } } } ``` I'm using Samsung GT-6200L with stock Android 3.2