I did caught all unHandled Exceptions in my android app like the common way:
public class AppContext extends Application{
public static Context context;
public void onCreate(){
super.onCreate();
AppContext.context = getApplicationContext();
// Setup handler for uncaught exceptions.
Thread.setDefaultUncaughtExceptionHandler (new Thread.UncaughtExceptionHandler()
{
@Override
public void uncaughtException (Thread thread, Throwable e)
{
handleUncaughtException (thread, e);
}
});
}
public void handleUncaughtException (Thread thread, Throwable e)
{
Intent intent = new Intent (context, Login.class);
intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK); // required when starting from Application
startActivity (intent);
System.exit(1);
}
}
But despite that, the app sometimes(a little times) exits without any notice, and the log doesn't provide any crash messages, I don't know what else than an Exception can lead to that.
The app designed to be always running and not exiting whatever happens and that what makes me handle all uncaught Exceptions like the past way.
worth to mention some of the System.Err
messages I got in the LogCat (don't know if it would help and don't know if I got it in the moment of app exiting problem or not and don't even know if I get it from the app or not as the logcat didn't mention that):
1:
Window type can not be changed after the window is added; ignoring change of com.android.internal.policy.impl.PhoneWindow$DecorView{426c3e00 V.E..... R.....ID 0,0-0,0}
2:
java.lang.SecurityException: WifiService: Neither user 10086 nor current process has android.permission.CHANGE_WIFI_STATE.