Read through [1] and [2] "Errors are abnormal conditions that should never occur" and there is usually no recovering from it. You can catch it with "OutOfMemoryError" itself, with "Error" or with "Throwable" [3], if you need and try to display a message.
Best approach is to check what consumes memory and try to solve the problem. Android Device Monitor will come in handy with checking relevant details [4]. [1] http://javaconceptoftheday.com/difference-between-error-vs-exception-in-java/ [2] https://docs.oracle.com/javase/7/docs/api/java/lang/Error.html [3] https://docs.oracle.com/javase/tutorial/essential/exceptions/throwing.html [4] http://developer.android.com/tools/debugging/debugging-memory.html On Tue, Mar 8, 2016 at 6:29 PM, Julio Oliveira < [email protected]> wrote: > Try to use Exception ( this is for all errors ) > > On Tue, Mar 8, 2016 at 9:50 AM, Zishan J. <[email protected]> wrote: > > > Hello, > > > > I am using Commons.io.IOUtils library in my android application. I have > > received this error: > > > > Fatal Exception: java.lang.OutOfMemoryError > > at > org.apache.commons.io.output.ByteArrayOutputStream.needNewBuffer > > at org.apache.commons.io.IOUtils.toByteArray > > at com.alhuda.qih.DownloadCompleteReceiver.onReceive > > > > I have tried to catch with IOException but no luck. Is there any way to > > handle this exception, so I can show the user-friendly message instead of > > getting the application crashed? > > > > Regards, > > Zishan J. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > > > -- > Saludos > > Julio M. Oliveira - Buenos Aires > http://www.linkedin.com/in/juliomoliveira > > Software PYMES - Open Source > http://www.javatango.com/ <http://www.linkedin.com/in/juliomoliveira> >
