android


Android Progress Dialog not showing until the function finish running (AsyncTask)


When a button is clicked I'm calling the async class in a function and I need to show progressDialog until it runs the displaylist function. But it shows up only after the function finished running and closes immediately. Please help me what am I doing wrong here.
public class FilterAsyncTask extends AsyncTask<Void, Void, Void> {
ProgressDialog dispProgress;
#Override
protected void onPreExecute()
{
dispProgress = ProgressDialog.show(Filter.this, "Please wait...",
"Loading...", true, true);
}
protected Void doInBackground(Void... params) {
return null;
}
protected void onPostExecute(Void result) {
super.onPostExecute(result);
MerchantsActivity.displayList();
dispProgress.cancel();
finish();
}
}
Your AsyncTask will complete immediately because you do exactly nothing in doInBackground()! That's where your long-running background non-UI code is supposed to go...
I would recommend you not to use the static ProgressDialog#show method. Rather donew ProgressDialog() and initialize it accordingly and finally call show(). I have never used the static method and do not know how it works, but I have used the other option. Furthermore the static method seems to have no available documentation.

Related Links

Horizontal RecyclerView with items that have dynamic height
Still having issues removing android title bar
Android how to start activity without intent or backround
Android build failed when using react-native-googlesignin
onBackpressed() Going to same activity for first time
Playing Spotify Song from Intent After Search
If user puts multiple widget instances and rapidly clicks them, then service updates only last instance
Sleeping thread prevents file writing
GridView is empty when passing in Array of images
Android - How to use the same USB device with two apps running simultaneously?
Data encapsulation inside Android library project
Gradle. Resolved versions for compilation (x.x.x) and packaging (y.y.y) differ
Send inbox SMS to server via API
This application failed to start because it could not find or load the Qt platform plugin “android”
Drawing Image on Android
TextView real height with wrap_content single line

Categories

HOME
algorithm
django
grok
fabricjs
kentico
static
components
obfuscation
jelastic
solaris
telegram-bot
visual-studio-emulator
echo
settings
special-characters
elasticsearch-5
extjs4.2
google-schemas
java.util.logging
redis-sentinel
jsonpath
onedrive-api
symmetricds
symbol
job-scheduling
digital-signature
bourbon
swagger-2.0
replication
dynamically-generated
game-theory
siri
slidetoggle
fable-f#
motion-detection
amazon-quicksight
outliers
realm-mobile-platform
send
simplecv
android-gridview
gojs
twos-complement
watchman
graphhopper
apache-stanbol
stringtokenizer
android-ibeacon
print-css
contract
clang++
plan-9
user-defined-fields
x-ray
arq
arules
gpg-signature
rxtx
vcloud-director-rest-api
mapxtreme
custom-lists
segment-io
file-uri
rspec2
i386
synonym
dup
jclouds
http-status-code-401
thread-sleep
pushbots
state-restoration
graphics2d
cryptographichashfunction
at-job
android-cookiemanager
uncaught-typeerror
primitive-types
metatrader5
square-bracket
spring-3
c++builder-xe5
oocss
rolify
mvc-editor-templates
actiondispatch
font-awesome-4.0.0
argouml
pdfviewer
rmiregistry
mysql-error-1205
google-ajax-api
socketserver
metaweblog
undefined-index
delimited-text
nstokenfield
qtabbar
pagemethods
strtod
dojo-dnd
leader
pnrp

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App