0
在一些測試中,我設法凍結模擬器到我必須創建一個新的模擬器的點。在下面的代碼中我不小心拼錯了一個類名和Class.forName
threw
RuntimeException()
ClassNotFoundException
。 ActivityManager
然後執行Start proc org.acra.CrashReportDialog
。這是循環運行並凍結模擬器可能是因爲onCreate()
永遠不會完成,不確定。Acra重新啓動一遍又一遍,並凍結模擬器
當模擬器開始我有一個啓動我的應用程序的android.permission.RECEIVE_BOOT_COMPLETED
。
任何方式來防止這種情況旁邊代碼Application
onCreate()
或編寫更好的代碼。
public class Application extends android.app.Application {
@Override
public void onCreate() {
super.onCreate();
ACRA.init(this);
ACRA.getErrorReporter().setReportSender(new AcraReportSender(this));
// gets id, create it if it dose not exist
ACRA.getErrorReporter().putCustomData("APPLICATION_ID_UUID", SettingsManager.applicationId());
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
ArrayList<String> contactManager = new ArrayList<String>();
TypedArray contactManagerClasses = getResources().obtainTypedArray(R.array.contact_managers);
for (int index = 0; index < contactManagerClasses.length(); index++)
contactManager.add(contactManagerClasses.getString(index));
contactManagerClasses.recycle();
TypedArray managerClasses = getResources().obtainTypedArray(R.array.managers);
for (int index = 0; index < managerClasses.length(); index++)
if (isContactsSupported() || !contactManager.contains(managerClasses.getString(index)))
try {
Class.forName(managerClasses.getString(index));
Log.d("Application","LOADING MANAGER " + managerClasses.getString(index));
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
managerClasses.recycle();
TypedArray tableClasses = getResources().obtainTypedArray(R.array.tables);
for (int index = 0; index < tableClasses.length(); index++)
try {
Class.forName(tableClasses.getString(index));
Log.d("Application","LOADING TABLE " + managerClasses.getString(index));
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
tableClasses.recycle();
onServiceStarted();
}
......
....
是的,當然,我掛斷了阿克拉,但你可能是對的 – Erik