如何以编程崩溃Android应用程序? [英] How to crash an Android app programmatically?

查看:130
本文介绍了如何以编程崩溃Android应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用测试一下崩溃报告 ACRA ,但第一步是我需要使用code,以模拟在Android中一个致命的碰撞。

你知道吗?

解决方案

 只需执行此code:被零除
 

更新:也可以试试这个 创建一个方法,

 公共无效计算器(){
        this.stackOverflow();

    }
 

和调用这个地方/ buttonClick

或者干脆抛出一个未捕获的异常

 抛出新的RuntimeException(这是一个崩溃);
 

宾果!

I want to test out crash report using acra but the first step is I need to simulate a fatal crash in Android using code.

Any idea?

解决方案

Just execute this code: divide by zero

Update: Also can try this Create a method,

public void stackOverflow() {
        this.stackOverflow();

    }

And call this somewhere/buttonClick

OR simply throw an uncaught exception

throw new RuntimeException("This is a crash");

Bingo!

这篇关于如何以编程崩溃Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆