我设计了一个应用程序的Android,在我显示的主要活动已启动,但应用程序需要5-7秒开始在低端设备之前启动画面。 我想,以减少时间尽可能低。 我一直在试图减少在做的事情onCreate()
但现在我不能去除更多的从任何东西。 我粘贴,我已经习惯了显示启动和MainActivity代码的代码。 请帮我减少了应用程序的启动时间。
Splash.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_splash);
txtLoad = (TextView) findViewById(R.id.txtLoading);
txtLoad.setText("v1.0");
new Thread() {
public void run() {
try {
sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
finish();
Intent intent = new Intent(SplashActivity.this,MainActivity.class);
startActivity(intent);
}
}
}.start();
}
MainActivity.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
editType1UserName = (EditText) findViewById(R.id.editTextType1UserName);
editType1Password = (EditText) findViewById(R.id.editTextType1Password);
editType2UserName = (EditText) findViewById(R.id.editTextType2UserName);
editType2Password = (EditText) findViewById(R.id.editTextType2Password);
editType3UserName = (EditText) findViewById(R.id.editTextType3UserName);
editType3Password = (EditText) findViewById(R.id.editTextType3Password);
editType4UserName = (EditText) findViewById(R.id.editTextType4UserName);
editType4Password = (EditText) findViewById(R.id.editTextType4Password);
mTxtPhoneNo = (AutoCompleteTextView) findViewById(R.id.mmWhoNo);
mTxtPhoneNo.setThreshold(1);
editText = (EditText) findViewById(R.id.editTextMessage);
spinner1 = (Spinner) findViewById(R.id.spinnerGateway);
btnsend = (Button) findViewById(R.id.btnSend);
btnContact = (Button) findViewById(R.id.btnContact);
btnsend.setOnClickListener((OnClickListener) this);
btnContact.setOnClickListener((OnClickListener) this);
mPeopleList = new ArrayList<Map<String, String>>();
PopulatePeopleList();
mAdapter = new SimpleAdapter(this, mPeopleList, R.layout.custcontview,
new String[] { "Name", "Phone", "Type" }, new int[] {
R.id.ccontName, R.id.ccontNo, R.id.ccontType });
mTxtPhoneNo.setAdapter(mAdapter);
mTxtPhoneNo.setOnItemClickListener((OnItemClickListener) this);
readPerson();
Panel panel;
topPanel = panel = (Panel) findViewById(R.id.mytopPanel);
panel.setOnPanelListener((OnPanelListener) this);
panel.setInterpolator(new BounceInterpolator(Type.OUT));
getLoginDetails();
}