I know this question was published some time ago, and many times! Yesterday I fell into this trap, and I thought that I would publish what I found.
Definition of the problem: I used the following code
public class myAppActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); try { -- lots of code -- } catch (Exception ex) { Log.e ("eTutorPrism Error", "Caught this exception " + ex); ex.printStackTrace(); } } } Symptom was that 'ex' was always null and resume will give NullPointerException, although the actual exception was an IllegalArgumentException in a call made into another class from the code above.
RESEARCH: onCreate () code does not display an exception. instead, it shows exception = null.
Solution: DO NOT use too much processing in onCreate (). Move as much as possible to another thread. So I changed the code to look like this. voila, it works !!! I see the actual exception being displayed in Logcat.
public class eTutorPrismAppActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); eTutorPrismTest myTest = new eTutorPrismTest (getApplicationContext()); myTest.start(); } } class eTutorPrismTest extends Thread { private Context m_AppContext = null; public eTutorPrismTest (Context appContext) { m_AppContext = appContext; } public void run () { -- lots of code that needs appContext -- } }
source share