No exception, but StrictMode displays a message on System.err just before it completes. So, this is a hack, but it works, and since it will only be included in debug builds, I believe that this is normal ... :)
in onCreate() :
//monitor System.err for messages that indicate the process is about to be killed by //StrictMode and cause a heap dump when one is caught System.setErr (new HProfDumpingStderrPrintStream (System.err));
and the class referenced by:
private static class HProfDumpingStderrPrintStream extends PrintStream { public HProfDumpingStderrPrintStream (OutputStream destination) { super (destination); } @Override public synchronized void println (String str) { super.println (str); if (str.equals ("StrictMode VmPolicy violation with POLICY_DEATH; shutting down.")) {
(where app is a static field in an external class containing a link to the application context, for the convenience of links)
The line in which it matches remained unchanged from the release of gingerbread until the jelly bean, but could theoretically change in future versions, so itβs worth checking out new releases so that they still use the same message.
Jules Mar 08 '13 at 20:37 2013-03-08 20:37
source share