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

SugarORM : While instrumentation testing, No such table Exception
Getting updated data from realm
Fragment do not work correct after recreate process
EditText is being rendered incorrectly
Changing order in viewholder
Bonjour(IPP) vs Jetdirect-Socket Printer
Convert MANUFACTURER plus MODEL into Phone Name
BroadcastReceiver does not trigger
Intent ACTION_CALL is not being intercepted by my application
Button “MyButton” is never used
Dynamically adding to listView in a fragment from mainActivity
Data does not reload automatically in a Fragment inside ViewPager
how to show dialog from my application for result (like google play game)
error in android studio log cat need help..open gl FBO not found
Android - Run/debug background service [duplicate]
Can findViewById(android.R.id.content) ever return null for Snackbars?

Categories

HOME
fpga
sitecore
r-googlesheets
rendering
bitbucket-api
newrelic
regular-language
x264
angularfire2
rcloud
sendgrid-api-v3
dkim
ycsb
jxl
xcodebuild
pybossa
renjin
qsqlquery
microsoft-dynamics-nav
cfml
jquery-ias
gulp-watch
ember-cli
roslyn
easeljs
highstock
roundup
jboss6.x
surveymonkey
flooding
amazon-quicksight
nstimer
entity-relationship-model
handler
corenlp-server
mobx
quickfixj
glib
android-sugarorm
modernizr
amazon-ses
odroid
gdata
linqpad
subclipse
oracle-service-bus
facebook-social-plugins
monkey-testing
sonarlint-eclipse
identification
page-replacement
aquamacs
type-theory
d3-force-directed
polyline
builtins
redistributable
file-uri
jodd
jclouds
udpclient
swizzling
design-principles
phpgrid
concurrentmodification
decimalformat
tfs-workitem
dllimport
rubaxa-sortable
opserver
sony-lifelog-api
ember-cli-rails
liquid-layout
alloy-ui
google-refine
mraid
cakephp-2.7
ejb-2.x
variadic-templates
boost-program-options
ignite-ui
live555
grails-plugin-rabbitmq
dct
dot42
vsx
websphere-esb
multitasking
jammer
rolify
scringo
bjyauthorize
extreme-programming
sentestingkit
uimanageddocument
listitem
koken
convention
entity-attribute-value
catransform3d
automationelement
cuteeditor
appledoc
pagemethods
django-piston
web-application-project
interop-domino

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App