Home key and other reasons, the program will become a background program, the system will be more necessary, may be recycled resources, and then open, it will be due to resource recycling, and then call OnCreate, no intent parameters and cause the program to crash.
In this case, there are two ways we can deal with it:
@Override protected void Onsaveinstancestate (Bundle outstate) {//TODO auto-generated method stub Super.onsave Instancestate (outstate); } Save the parameters so that the next time you start, you will find the resources in intent =null, using the saved parameters directly.
Another way to deal with this is to add exception handling in OnCreate.
When you encounter an exception, restart the program.
To restart the Android program code:
Intent i = Getbasecontext (). Getpackagemanager () . Getlaunchintentforpackage (Getbasecontext (). Getpackagename ()) ; I.addflags (Intent.flag_activity_clear_top);
Make a small ad for my own little website: Programmer's Programming prerequisite software network www.uhdesk.com