1 第一步我们加日志打印
package com.example.myapplication;
import android.app.Application;
import android.util.Log;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Log.d("XL_DBG","how application start :", new Throwable());
}
}
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("XL_DBG","how startActivity work",new Throwable());
setContentView(R.layout.activity_main);
}
}
2 得到打印
2019-11-05 13:53:51.442 20175-20175/com.example.myapplication D/XL_DBG: how application start :
java.lang.Throwable
at com.example.myapplication.MyApplication.onCreate(MyApplication.java:10)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1158)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6266)
at android.app.ActivityThread.access$1200(ActivityThread.java:240)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7094)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
2019-11-05 13:53:51.645 20175-20175/com.example.myapplication D/XL_DBG: how startActivity work
java.lang.Throwable
at com.example.myapplication.MainActivity.onCreate(MainActivity.java:13)
at android.app.Activity.performCreate(Activity.java:7340)
at android.app.Activity.performCreate(Activity.java:7331)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1275)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3106)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3269)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1960)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7094)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
其中Application启动中
handleBindApplication(AppBindData data)
比较重要,此处data 包含了Application启动的一系列参数,据此可以workaround。