package com.njnu.kai.practice;


import android.content.Intent;
import android.os.Handler;
import android.os.SystemClock;

import com.evernote.android.job.JobManager;
import com.jakewharton.threetenabp.AndroidThreeTen;
import com.njnu.kai.practice.aidl.AidlTestFragment;
import com.njnu.kai.practice.aidl.AidlTestService;
import com.njnu.kai.practice.job.DemoJobCreator;
import com.njnu.kai.practice.recycler.MultiTypeInstaller;
import com.njnu.kai.support.AppRuntime;
import com.njnu.kai.support.BaseApplication;
import com.njnu.kai.support.image.ImageLoader;

import java.io.File;

/**
 * @author hongkai.qian
 * @version 1.0.0
 * @since 14-4-29
 */
public class MainApplication extends BaseApplication {

    public static final boolean TEST_CONTINUE_CRASH = false;

    @Override
    public void onCreate() {
        super.onCreate();
        ImageLoader.init(AppRuntime.Storage.getCachePath(this) + File.separator + "imageTest");
//        Stetho.initializeWithDefaults(this);
        AndroidThreeTen.init(this);
        MultiTypeInstaller.start();

        JobManager.create(this).addJobCreator(new DemoJobCreator());

        if (TEST_CONTINUE_CRASH) {
            Intent intent = new Intent(getApplicationContext(), AidlTestService.class);
            startService(intent);

            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    int a = 20 / 0; //单纯的在application里制造crash基本不能造成连续crash,一般crash2次后停止
                }
            }, 100);
        }
    }
}

@@ -45,22 +45,77 @@
 oid.
-content.Intent
+app.Activity;%0Aimport android.content.Intent;%0Aimport android.os.Bundle
 ;%0Aim
@@ -562,16 +562,54 @@
 cation;%0A
+import com.njnu.kai.support.LogUtils;%0A
 import c
@@ -854,16 +854,78 @@
 = false;
+%0A    private TestLookActivityLifecycle mLookActivityLifecycle;
 %0A%0A    @O
@@ -1650,24 +1650,24 @@
           %7D%0A
-
             
@@ -1681,20 +1681,1797 @@
 ;%0A        %7D%0A
+        mLookActivityLifecycle = new TestLookActivityLifecycle();%0A        registerActivityLifecycleCallbacks(mLookActivityLifecycle);%0A    %7D%0A%0A    @Override%0A    public void onTerminate() %7B%0A        unregisterActivityLifecycleCallbacks(mLookActivityLifecycle);%0A        super.onTerminate();%0A    %7D%0A%0A    public static class TestLookActivityLifecycle implements ActivityLifecycleCallbacks %7B%0A%0A        private static final String TAG = %22TestLookActivityLifecycle%22;%0A%0A        @Override%0A        public void onActivityCreated(Activity activity, Bundle savedInstanceState) %7B%0A            LogUtils.i(TAG, %22onActivityCreated: %22 + activity.getClass().getSimpleName());%0A        %7D%0A%0A        @Override%0A        public void onActivityStarted(Activity activity) %7B%0A//            LogUtils.i(TAG, %22onActivityStarted: %22 + activity.getClass().getSimpleName());%0A        %7D%0A%0A        @Override%0A        public void onActivityResumed(Activity activity) %7B%0A//            LogUtils.i(TAG, %22onActivityResumed: %22 + activity.getClass().getSimpleName());%0A        %7D%0A%0A        @Override%0A        public void onActivityPaused(Activity activity) %7B%0A//            LogUtils.i(TAG, %22onActivityPaused: %22 + activity.getClass().getSimpleName());%0A        %7D%0A%0A        @Override%0A        public void onActivityStopped(Activity activity) %7B%0A//            LogUtils.i(TAG, %22onActivityStopped: %22 + activity.getClass().getSimpleName());%0A        %7D%0A%0A        @Override%0A        public void onActivitySaveInstanceState(Activity activity, Bundle outState) %7B%0A//            LogUtils.i(TAG, %22onActivitySaveInstanceState: %22 + activity.getClass().getSimpleName());%0A        %7D%0A%0A        @Override%0A        public void onActivityDestroyed(Activity activity) %7B%0A            LogUtils.i(TAG, %22onActivityDestroyed: %22 + activity.getClass().getSimpleName());%0A        %7D%0A
     %7D%0A%7D%0A

test look activity lifecycle