show dialog when application/activity startup [closed]
can we show the dialog when our appliaction/activity startup?
Sure you can show a dialog, look on the answer Displaying alerts in Activity.onCreate(..)
You can have a look at AsynTask. Amongst others there are three methods which can serve your requirement.
onPreExecute, onPostExetcute and doInBackground;
start the progress dialog in onPreExecute dismiss the progress dialog in onPostExetcute do you connection in doInBackground.
Hope that will serve your purpose.
http://www.droidnova.com/how-to-create-a-splash-screen,561.html
There appears to be lost of information on this - just Google it.
try this way in post execute display your database from database. and pre execute start dialog and post execute close it. if you want to show horizontal incrementing progress bar then in do in backgrond put that code that i have there.
private class DownloadImageTask extends AsyncTask {
protected Bitmap doInBackground(String... urls) {
while (myProgress<length){ myProgress=myProgress+1; myProgressBar.setProgress(myProgress); } return decodeImage(urls[0]); } protected void onPostExecute(Bitmap result) { dialog.dismiss(); imView.setImageBitmap(result); } protected void onPreExecute() { // Things to be done while execution of long running operation is in progress. For example updating ProgessDialog dialog = ProgressDialog.show(BusinessCardActivity.this, "Loading.........", "Wait For Few Second", true); } }
精彩评论