I am trying to log the start up latency of my app. They way I am doing it is setting the start time of the app on Application.onCreate
and provide a public method that returns the time.
MyApplication extends Application {
Date startUpTime;
//Declare variables
@Override
public void onCreate() {
super.onCreate();
setStartupTime();
//other initializations
}
private void setStartUpTime() {
startUpTime = new Date();
}
public Date getStartUpTime() {
return startUpTime;
}
}
MyActivity extends Activity {
.
.
.
@Override
public void onStart(){
logStartUpLatency();
//other onStart stuff
}
private void logStartUpLatency() {
Date currentTime = new Date();
Date startTime = (MyApplication)getApplicationContext().getStartUpTime();
long latency = currentTime.getTime() - startTIme.getTime();
Log.d("Start up Latency is ", Long.toString(latency)):
}
This is how I am testing my start up latency:
Does any one know why that might happen?
Update
So if I install the apk using "adb install -r myapk", the app isn't going through the Myapplication.onCreate()
.
So if I install the apk using "adb install -r myapk", the app isn't going through the Myapplication.onCreate(). So that answers this question. I will ask a separate question on why installing an application using "adb install -r myapk" and then starting myapk doesn't go through MyApplication.onCreate()