SafeLooper

General

Category
Free
Tag
Exception Handling
License
N/A
Registered
Aug 11, 2015
Favorites
4
Link
https://github.com/mmin18/SafeLooper
See also
Exception Handler
Cracker
ExceptionWear
Sofa
Recovery

Additional

Language
N/A
Version
N/A
Created
Jun 8, 2013
Updated
Jun 8, 2013 (Retired)
Owner
Tu Yimin (mmin18)
Contributor
Tu Yimin (mmin18)
1
Activity
Badge
Generate
Download
Source code
APK file

Advertisement

SafeLooper

SafeLooper catches unexpected exceptions in Android applications to avoid showing force close dialog.

A normal Android application (except games) is driven by event loop, known as android.os.Looper. When you throw a uncaught exception in the main thread, the main thread's looper will stop and Android will show a force close dialog. You won't have a chance to recover the main thread's looper since it has already stopped.

If you can create a sub looper, pull message from event queue and process it with a try-catch block, you can catch the unexpected exceptions and avoid the application from crash.

Here is how a SafeLooper works:

All you need to do is import SafeLooper.java into your project and call SafeLooper.install() when your application start.

// install SafeLooper in main thread
SafeLooper.install();

// receive the uncaught exception if you don't want to ignore it
SafeLooper.setUncaughtExceptionHandler(...);

You can also test the https://raw.github.com/mmin18/SafeLooper/master/safelooper.apk on your device.