How do I catch a static java.lang.UnsatisfiedLinkError from Android and show the user a better error message? -


my application loads various shared objects when created. catch errors thrown because of shared objects not being present on device , show better error message user. how achieve this?

i can catch java.lang.unsatisfiedlinkerror so

static {     try     {         system.loadlibrary("myapplication");     }     catch(java.lang.unsatisfiedlinkerror e)     {         if(e.getmessage().contains("libsharedobject"))         {             log.e( tag, "this device not support ..." );         }         else         {             throw e;         }     } } 

but toast.maketext(...).show() , other application message boxes won't work because application die in oncreate() because of previous error.

is there way of changing systems default error message of "unfortunately there error.."? or way of displaying error message process or android os?

i found answer using this answer. catch exception in static {} block, set member variable there error , message, create new thread displays error using toast , use looper call message loop in thread. need sleep main thread while though before let application crash.

static boolean mwaserror = false; static string merrormessage = "";  static {     try     {         system.loadlibrary("myapplication");     }     catch(java.lang.unsatisfiedlinkerror e)     {         if(e.getmessage().contains("libopencl"))         {             log.e( tag, "this device not support opencl" );             mwaserror = true;             merrormessage = "this device not support opencl";         }         else         {             throw e;         }     } }   @override protected void oncreate( bundle savedinstancestate ) {     if(mwaserror)     {         new thread() {             @override             public void run() {                 looper.prepare();                 toast.maketext(getapplicationcontext(), merrormessage, toast.length_short).show();                 looper.loop();              }         }.start();          try         {             thread.sleep(10000);         }         catch(interruptedexception e)         {         }     }      // crash here if there error     super.oncreate(savedinstancestate); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -