Wednesday, July 25, 2012

Apertium Android with crash detection

Some device doesn't have enough RAM to support cache feature for translation and hence get crashed due to Low Memory. At the time of crash, App report it to app preference and close itself gracefully. So in next run, advance feature like cache can be switched off.
Figure 1
Main screen with crash detection message 

Code for crash report of ApertiumActivity.java

     //Saving and setting crash happen flag
     
     Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
   @Override
            public void uncaughtException(Thread t, Throwable e) {
          Translator.clearCache();
          String error = e.getMessage();
          Log.e("Error", error);
          appPreference.ReportCrash(error);
          progressDialog.dismiss();
          thisActivity.finish();
          android.os.Process.killProcess(android.os.Process.myPid());
          
          }
        });


Follow on GitHub

See source Code
Download APK

No comments:

Post a Comment