Answer the question
In order to leave comments, you need to log in
Initializing an Android application - how to get rid of brakes at startup?
Hello!
Now he is engaged in the development of an android application, its essence is to save the user's location in a local log, so that he can then see where he was during the day.
Now my suspicions fall on the fact that this problem is most likely related to the fact that initialization is performed in a class that is inherited from MultiDexApplication in the onCreate method (that is, the UI thread is clogged.).
On the other hand, this initialization must be done before you start using the application (before you switch to some kind of activity).
Below is a piece of code from the App class. Maybe you can advise something?
@Override
public void onCreate() {
super.onCreate();
// инициализировать библиотеку для работы с кастомными шрифтами, назначить Roboto Regular по умолчанию
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Roboto-Regular.ttf")
.setFontAttrId(R.attr.fontPath)
.build()
);
// инициализировать библиотеку для закачивания изображений из сети
Fresco.initialize(this);
App.context = getApplicationContext();
// инициализировать автоматическую отправку изображений
ACRA.init(this);
// инициализировать схему базы данных
DbHelper instance = DbHelper.getInstance();
Logger.info(getClass(), "Db helper initialized: "+instance);
//запуск и привязка созданного сервиса, отвественного за получения обновлений Location'a с App переменной
Intent intent = new Intent(this, AndroidLocationService.class);
bindService(intent, new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
Logger.info(getClass(), "on service conntected");
androidLocationService = ((ServiceAwareBinder<AndroidLocationService>)service).getService();
}
@Override
public void onServiceDisconnected(ComponentName name) {
androidLocationService = null;
}
}, Context.BIND_AUTO_CREATE);
startService(intent);
}
@Override
public void onCreate() {
super.onCreate();
App.context = getApplicationContext();
App.instance = this;
}
Answer the question
In order to leave comments, you need to log in
Opt out of synchronous service. Check fresco initialization speed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question