1.安卓的异常分为运行异常和编译异常
2.异常捕获的原理
Thread.UncaughtExceptionHandler 是 Java 虚拟机处理由于未捕获异常而导致程序停止运行的接口当一个线程由于未捕获异常而停止运行的时候,Java 虚拟机就会通过 Thread的getUncaughtExceptionHandler() 方法拿到当前 Thread 的 Thread.UncaughtExceptionHandler,并调用该 Thread.UncaughtExceptionHandler 的
uncaughtException 方法。
-
捕获异常后,如何优雅退出
android.os.Process.killProcess(android.os.Process.myPid()); System.exit(10);
4.bugly的使用和场景
注册bugly,继承bugly,写个bug看log
布局文件只写个button 按钮
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello World!"
android:onClick="click"
/>
在AndroidManifest.xml 清单文件中 注册
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name=".EHApplication">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
在MainActivity中的代码
package