What is the difference between ANR and crash in Android?

前端 未结 13 2258
北海茫月
北海茫月 2020-12-07 22:56

I have searched on the internet regarding what an ANR is. And I studied those references as well. But I don\'t get details regarding a crash in Android.

Can someone

13条回答
  •  孤城傲影
    2020-12-07 23:20

    ANR and Crash Examples:

    This question already has an accepted answer, but I am adding 2 simple examples to understand ANR and Crash better.

    ANR:

    // this will produce an ANR on your app
    int i = 0;
    while(true) {
        i++;
    }
    

    Crash:

    // this will crash your app : will produce java.lang.ArithmeticException
    int value = 5, i = 0;
    int result = value / i;
    

提交回复
热议问题