M
M
masterworks2015-08-04 01:05:12
MySQL
masterworks, 2015-08-04 01:05:12

AsyncTask is not relevant. Is it so?

When checking the test task, I was told that the use of AsyncTask in an Android application has not been relevant for a long time. Since there was no response to the counter letter, I ask for advice here.
Is AsyncTask really deprecated? Should I use other means of executing code in a background thread, and if so, which ones?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Andrey, 2019-01-10
@VladimirAndreev

DATE_FORMAT

T
ThunderCat, 2019-01-10
@ThunderCat

According to the mind - date / time formatting is given in jap, the task of the database is to store data in a certain format. If it is critical to do this using database tools, use DATE_FORMAT, as Andrey wrote to you above .
I would choose and in jap already parse the date into the desired format. SELECT `DateTimeOp` As Date

A
Andrew K, 2015-08-05
@masterworks

What exactly did you use Async Task for?
Async Task has some, let's say, peculiarities in the application, if they are not taken into account, then you can get problems. Offhand, for example:
- All Async Tasks are executed in ONE background thread, in turn.
- If you run Async Task on a long task and cause a screen orientation change, then the Activity that launched Async Task will be destroyed, but Async Task itself will continue to work. Moreover, upon completion, it will try to give the data to the destroyed Activity, as a result, the work was done in vain. An exception may also be thrown if the Async Task tries to access the View of the destroyed Activity.
- Various memory leaks. For example, an Async Task implemented as an inner class in an Activity will prevent the Activity from being garbage collected while the Async Task is running.
You can read about leaks here:
habrahabr.ru/company/sebbia/blog/243537
habrahabr.ru/company/badoo/blog/240479
In short, Async Task is used for short (seconds) and rare tasks. It is necessary to clearly understand what exactly this class is suitable for, otherwise you can break firewood. You need to understand the principles of operation of Async Task, Loaders, Services and be able to justify their use.

I
IceJOKER, 2015-08-04
@IceJOKER

Strange, in my opinion it is very relevant, and of. I don't see the Deprecated flag - developer.android.com/intl/ru/reference/android/os...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question