-
@param context
-
@return
*/
private boolean dexOptDone(Context context) {
SharedPreferences sp = context.getSharedPreferences(
DeviceUtil.getVersionName(context), MODE_MULTI_PROCESS);
return sp.getBoolean(“dexoptdone”, false);
}
/**
-
在单独进程中提前进行DexOpt的优化操作;主进程进入等待状态。
-
@param base
*/
public void preLoadDex(Context base) {
Intent intent = new Intent(Application.this, PreLoadDexActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
base.startActivity(intent);
while (!dexOptDone(base)) {
try {
//主线程开始等待;直到优化进程完成了DexOpt操作。
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
然后在PreLoadDexActivity中执行优化的操作,完成后修改标示&#