Search Results

Search found 112 results on 5 pages for 'progressdialog'.

Page 1/5 | 1 2 3 4 5  | Next Page >

  • What is best way to remove ProgressDialog

    - by Sunil Kumar Sahoo
    I have created a progress dialog by ProgressDialog progressDialog = null; // create instance variable of ProgressDialog int dialogID = 1; //to create progress dialog protected Dialog onCreateDialog(int id) { progressDialog = new ProgressDialog(context); progressDialog.setMessage(message); progressDialog.setIcon(android.R.id.icon); return progressDialog; } // to show progressdialog showDialog(dialogID); To remove the dialog I am able to use any of the following three approaches approach-1 if(progressDialog != null){ progressDialog.dismiss(); } approach-2 if(progressDialog != null){ progressDialog.cancel(); } approach-3 removeDialog(dialogID); I found second approach is more effective than first approach. and if I have to use with more than one progressdialog it is easier to use approach-3. But what is the best way to destroy a progressdialog and How?

    Read the article

  • Android: ProgressDialog.show() crashes with getApplicationContext

    - by Felix
    I can't seem to grasp why this is happening. This code: mProgressDialog = ProgressDialog.show(this, "", getString(R.string.loading), true); works just fine. However, this code: mProgressDialog = ProgressDialog.show(getApplicationContext(), "", getString(R.string.loading), true); throws the following exception: W/WindowManager( 569): Attempted to add window with non-application token WindowToken{438bee58 token=null}. Aborting. D/AndroidRuntime( 2049): Shutting down VM W/dalvikvm( 2049): threadid=3: thread exiting with uncaught exception (group=0x4001aa28) E/AndroidRuntime( 2049): Uncaught handler: thread main exiting due to uncaught exception E/AndroidRuntime( 2049): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tastekid.TasteKid/com.tastekid.TasteKid.YouTube}: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application E/AndroidRuntime( 2049): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401) E/AndroidRuntime( 2049): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) E/AndroidRuntime( 2049): at android.app.ActivityThread.access$2100(ActivityThread.java:116) E/AndroidRuntime( 2049): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) E/AndroidRuntime( 2049): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 2049): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 2049): at android.app.ActivityThread.main(ActivityThread.java:4203) E/AndroidRuntime( 2049): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 2049): at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime( 2049): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) E/AndroidRuntime( 2049): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) E/AndroidRuntime( 2049): at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime( 2049): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application E/AndroidRuntime( 2049): at android.view.ViewRoot.setView(ViewRoot.java:460) E/AndroidRuntime( 2049): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) E/AndroidRuntime( 2049): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) E/AndroidRuntime( 2049): at android.app.Dialog.show(Dialog.java:238) E/AndroidRuntime( 2049): at android.app.ProgressDialog.show(ProgressDialog.java:107) E/AndroidRuntime( 2049): at android.app.ProgressDialog.show(ProgressDialog.java:90) E/AndroidRuntime( 2049): at com.tastekid.TasteKid.YouTube.onCreate(YouTube.java:45) E/AndroidRuntime( 2049): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123) E/AndroidRuntime( 2049): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364) E/AndroidRuntime( 2049): ... 11 more Any ideas why this is happening? I'm calling this from the onCreate method.

    Read the article

  • Android: ProgressDialog doesn't show

    - by Select0r
    Hi, I'm trying to create a ProgressDialog for an Android-App (just a simple one showing the user that stuff is happening, no buttons or anything) but I can't get it right. I've been through forums and tutorials as well as the Sample-Code that comes with the SDK, but to no avail. This is what I got: btnSubmit.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { (...) ProgressDialog pd = new ProgressDialog(MyApp.this); pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pd.setMessage("Working..."); pd.setIndeterminate(true); pd.setCancelable(false); // now fetch the results (...long time calculations here...) // remove progress dialog pd.dismiss(); I've also tried adding pd.show(); and messed around with the parameter in new ProgressDialog resulting in nothing at all (except errors that the chosen parameter won't work), meaning: the ProgressDialog won't ever show up. The app just keeps running as if I never added the dialog. I don't know if I'm creating the dialog at the right place, I moved it around a bit but that, too, didnt't help. Maybe I'm in the wrong context? The above code is inside private ViewGroup _createInputForm() in MyApp. Any hint is appreciated, Greetings, Select0r

    Read the article

  • ProgressDialog won't show, even in onPreExecute of AsyncTask

    - by Geltrude
    In my class, Main extends Activity, I've this: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case ... case CREDENTIAL_VIEW: new SetStatusProgressBar(this).execute(); And there is this nested class: private class SetStatusProgressBar extends AsyncTask<String, Void, Boolean> { private ProgressDialog dialog; private Main ctx; public SetStatusProgressBar(Main ctx) { this.ctx = ctx; dialog = new ProgressDialog(ctx); } // progress dialog to show user that contacting server. protected void onPreExecute() { this.dialog = ProgressDialog.show(ctx, null, "Refreshing data from server...", true, false); } @Override protected void onPostExecute(final Boolean success) { //... //statements that refresh UI //... if (dialog.isShowing()) { dialog.dismiss(); timerProgressBarStop(); } } protected Boolean doInBackground(final String... args) { //... //statements to download data from server //... return true; } } In the Main class I open a second Activity, in this way: Intent myIntent = new Intent(Main.this, Credentials.class); startActivityForResult(myIntent, CREDENTIAL_VIEW); That second Activity returns to the Main activity in this way: Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); I don't understand why when I navigate from the second Activity to the Main, the ProgressDialog will show ONLY AFTER that the UI refreshes... In this way the Progress Dialog stays on the screen only for half second... and then hides! :( I'd like to see the ProgressDialog on top during all the download time! Help, please. Thank you all

    Read the article

  • Android ProgressDialog inside another dialog

    - by La bla bla
    I'm working on a game using AndEngine, and I need to show the users the list of his Facebook friends. I've created my custom Adatper and after the loading finishes everything works great. I have a problem with the loading it self. The ListView is inside a custom dialog, since I don't really know how to create one using AndEngine, So inside this dialog, I'm running an AsyncTask to fetch the friends' info, in that AsyncTask I'm have a ProgressDialog. The problem is, the ProgressDialog shows up behind the dialog that contains the to-be list (which while loading, is just the title). I can see the ProgressDialog "peeking" behind that dialog.. Any Ideas? Here's some code: FriendsDialog.java private ProgressDialog dialog; //Constructor of the AsyncTask public FriendsLoader(Context context) { dialog = new ProgressDialog(context); dialog.setMessage("Please wait..\nLoading Friends List."); } @Override protected void onPreExecute() { dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); dialog.setView(inflater.inflate(R.layout.loading, null)); dialog.setMessage("Please wait..\nLoading friends."); dialog.show(); } @Override protected void onPostExecute(ArrayList<HashMap<String, Object>> data) { if (dialog.isShowing()) { dialog.dismiss(); } MyAdapter myAdapter = new MyAdapter(context, data); listView = (ListView) findViewById(R.id.list); listView.setAdapter(myAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> myAdapter, View myView, int myItemInt, long mylng) { String id = (String) listView.getItemAtPosition(myItemInt); listener.onUserSelected(id); dismiss(); } }); }

    Read the article

  • ProgressDialog does not disappear after executing dismiss, hide or cancel?

    - by Martin
    Hello, I have an Overlay extension which has 2 dialogs as private attributes - one Dialog and one ProgressDialog. After clicking on the Overlay in the MapView, the Dialog object appears. When the user clicks a button in the Dialog it disappears and the ProgressDialog is shown. Simultaneously a background task is started by notifying a running Service. When the task is done, a method (buildingLoaded) in the Overlay object is called to switch the View and to dismiss the ProgressDialog. The View is being switched, the code is being run (I checked with the debugger) but the ProgressDialog is not dismissed. I also tried hide() and cancel() methods, but nothing works. Can somebody help me? Android version is 2.2 Here is the code: public class LODOverlay extends Overlay implements OnClickListener { private Dialog overlayDialog; private ProgressDialog progressDialog; .............. @Override public void onClick(View view) { ....... final Context ctx = view.getContext(); this.progressDialog = new ProgressDialog(ctx); ListView lv = new ListView(ctx); ArrayAdapter<String> adapter = new ArrayAdapter<String>(ctx, R.layout.layerlist, names); lv.setAdapter(adapter); final LODOverlay obj = this; lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String name = ((TextView) view).getText().toString(); Intent getFloorIntent = new Intent(Map.RENDERER); getFloorIntent.putExtra("type", "onGetBuildingLayer"); getFloorIntent.putExtra("id", name); view.getContext().sendBroadcast(getFloorIntent); overlayDialog.dismiss(); obj.waitingForLayer = name; progressDialog.show(ctx, "Loading...", "Wait!!!"); } }); ....... } public void buildingLoaded(String id) { if (null != this.progressDialog) { if (id.equals(this.waitingForLayer)) { this.progressDialog.hide(); this.progressDialog.dismiss(); ............ Map.flipper.showNext(); // changes the view } } } }

    Read the article

  • Running a ProgressDialog MonoAndroid

    - by user1791926
    I am trying to run a progressDialog that will loading items into a Sqlite datebase on a first load for my application. I get an error message because the application runs the rest of the code in the application before the rest of the data is loaded into the database. How do I make sure the code is completed in the progressDialog before the code in the rest of the program? LocalDatabase DB = new LocalDatabase(); var dbpd = ProgressDialog.Show(this, "Loading Database", "Please wait Loading Data",true); ThreadPool.QueueUserWorkItem((s) =>{ DB.createDB(); RunOnUiThread(() => databaseLoaded()); });

    Read the article

  • Android ProgressDialog Progress Bar doing things in the right order

    - by FauxReal
    I just about got this, but I have a small problem in the order of things going off. Specifically, in my thread() I am setting up an array that is used by a Spinner. Problem is the Spinner is all set and done basically before my thread() is finished, so it sets itself up with a null array. How do I associate the spinners ArrayAdapter with an array that is being loaded by another thread? I've cut the code down to what I think is necessary to understand the problem, but just let me know if more is needed. The problem occurs whether or not refreshData() is called. Along the same lines, sometimes I want to call loadData() from the menu. Directly following loadData() if I try to fire a toast on the next line this causes a forceclose, which is also because of how I'm implementing ProgressDialog. THANK YOU FOR LOOKING public class CMSHome extends Activity { private static List<String> pmList = new ArrayList<String>(); // Instantiate helpers PMListHelper plh = new PMListHelper(); ProjectObjectHelper poc = new ProjectObjectHelper(); // These objects hold lists and methods for dealing with them private Employees employees; private Projects projects; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Loads data from filesystem, or webservice if necessary loadData(); // Capture spinner and associate pmList with it through ArrayAdapter spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>( this, android.R.layout.simple_spinner_item, pmList); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); //---the button is wired to an event handler--- Button btn1 = (Button)findViewById(R.id.btnGetProjects); btn1.setOnClickListener(btnListAllProjectsListener); spinner.setOnItemSelectedListener(new MyOnItemSelectedListener()); } private void loadData() { final ProgressDialog pd = ProgressDialog.show(this, "Please wait", "Loading Data...", true, false); new Thread(new Runnable(){ public void run(){ employees = plh.deserializeEmployeeData(); projects = poc.deserializeProjectData(); // Check to see if data actually loaded, if not then refresh if ((employees == null) || (projects == null)) { refreshData(); } // Load up pmList for spinner control pmList = employees.getPMList(); pd.dismiss(); } }).start(); } private void refreshData() { // Refresh data for Projects projects = poc.refreshData(); poc.saveProjectData(mCtx, projects); // Refresh data for PMList employees = plh.refreshData(); plh.savePMData(mCtx, employees); } } <---- EDIT ----- I tried changing loadData() to the following after Jims suggestion. Not sure if I did this right, still doesn't work: private void loadData() { final ProgressDialog pd = ProgressDialog.show(this, "Please wait", "Loading Data...", true, false); new Thread(new Runnable(){ public void run(){ employees = plh.deserializeEmployeeData(); projects = poc.deserializeProjectData(); // Check to see if data actually loaded, if not return false if ((employees == null) || (projects == null)) { refreshData(); } pd.dismiss(); runOnUiThread(new Runnable() { public void run(){ // Load up pmList for spinner control pmList = employees.getPMList(); } }); } }).start(); }

    Read the article

  • ProgressDialog does not display until after AsyncTask completes

    - by tedwards
    I am trying to display an indefinite ProgressDialog, while an AsyncTask binds to a RemoteService. The RemoteService builds a list of the users contacts when the service is first created. For a long list of contacts this may take 5~10 seconds. The problem I am having, is that the ProgressDialog does not display until after the RemoteService has built it's list of contacts. I even tried putting a Thread.sleep in to give the ProgressDialog time to show up. With the sleep statement the ProgressDialog loads and starts spinning, but then locks up as soon as the RemoteService starts doing it's work. If I just turn the AsyncTask into dummy code, and just let it sleep for a while, everything works fine. But when the task has to do actual work, it is like the UI just sits and waits. Any ideas on what Im doing wrong ? @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(IM,"Start Me UP!!"); setContentView(R.layout.main); Log.d(IM, "Building List View for Contacts"); restoreMe(); if (myContacts==null){ myContacts = new ArrayList<Contact>(); this.contactAdapter = new ContactAdapter(this, R.layout.contactlist, myContacts); setListAdapter(this.contactAdapter); new BindAsync().execute(); } else{ this.contactAdapter = new ContactAdapter(this, R.layout.contactlist, myContacts); setListAdapter(this.contactAdapter); } } private class BindAsync extends AsyncTask<Void, Void, RemoteServiceConnection>{ @Override protected void onPreExecute(){ super.onPreExecute(); Log.d(IM,"Showing Dialog"); showDialog(DIALOG_CONTACTS); } @Override protected RemoteServiceConnection doInBackground(Void... v) { Log.d(IM,"Binding to service in BindAsync"); try{ Thread.sleep(2000); } catch (InterruptedException e){ } RemoteServiceConnection myCon; myCon = new RemoteServiceConnection(); Intent i = new Intent(imandroid.this,MyRemoteService.class); bindService(i, myCon, Context.BIND_AUTO_CREATE); startService(i); Log.d(IM,"Bound to remote service"); return myCon; } @Override protected void onPostExecute(RemoteServiceConnection newConn){ super.onPostExecute(newConn); Log.d(IM,"Storing remote connection"); conn=newConn; } };

    Read the article

  • Find TableLeyout in a thread (Because of the ProgressDialog)

    - by Shaulian
    Hi all, On my activity, im getting some big data from web, and while getting this data i want to show the user a ProgressDialog with spinning wheel. That i can do only with putting this code into a thread, right ? the problem is that after im getting this data i need to insert it into my tableLayout as TableRows and it seems impossible to access the TableLayout from the thread. What can i do to show this progress dialog and to be able access the table layout from the thread ?? Is there any event that happens on the end of the thread ? My code fails for : _tableLayout.addView(_tableRowVar, new TableLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); My full code is : final ProgressDialog dialog = ProgressDialog.show(MyActivity.this, "", "Getting data.\nPlease wait...",true); new Thread() { public void run() { try { TableLayout _tableLayout; _tableLayout = (TableLayout)MyActivity.this.findViewById(R.id.tableLayoutID); List<String> data = getDataFromWeb(); // Get the data and bind it into the table publishTableLayoutWithTableRows(_tableLayout, data ); } catch (Exception e) { new AlertDialog.Builder(MyActivity.this) .setMessage(e.getMessage()) .show(); } dialog.dismiss(); } }.start();

    Read the article

  • show() progressdialog in asynctask inside fragment

    - by just_user
    I'm trying to display a progressDialog while getting an image from a url to a imageview. When trying to show the progressDialog the parent activity has leaked window... Strange thing is that I have two fragments in the this activity, in the first fragment this exact same way of calling the progressdialog works but when the fragment is replaced and i try to make it again it crashes. This is the asynctask I'm using inside the second fragment with the crash: class SkinPreviewImage extends AsyncTask<Void, Void, Void> { private ProgressDialog progressDialog; @Override protected void onPreExecute() { progressDialog = new ProgressDialog(getActivity()); progressDialog.setMessage("Loading preview..."); if(progressDialog != null) progressDialog.show(); progressDialog.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface arg0) { SkinPreviewImage.this.cancel(true); } }); } @Override protected Void doInBackground(Void... params) { try { URL newurl = new URL(url); Bitmap mIcon_val = BitmapFactory.decodeStream(newurl.openConnection().getInputStream()); skinPreview.setImageBitmap(mIcon_val); } catch (IOException e) { Log.e("SkinStoreDetail", e.getMessage()); } return null; } @Override protected void onPostExecute(Void v) { if(progressDialog != null) progressDialog.dismiss(); } } I've seen a few similar questions but the one closest to solve my problem used a groupactivity for the parent which I'm not using. Any suggestions?

    Read the article

  • Utiliser une ProgressDialog dans ses applications Android, par Axon de Tuto Mobile

    Axon_TutoMobile vous propose un article sur l'utilisation d' une ProgressDialog dans les applications Android Citation: Le but de ce tutorial est d'expliquer comment utiliser une ProgressDialog dans son application Android. Il peut être parfois utile d'afficher une barre de progression renseignant l'utilisateur sur l'avancement. Android fournit un moyen via la ProgressDialog pour les phases d'attente.

    Read the article

  • Small ProgressDialog "spinner" for android

    - by user141146
    Hi, I've been able to use the standard "ProgressDialog" for android to show that an indeterminate task is running But I'd like to use the "smaller" progress dialog "spinner" that's used for indeterminate tasks in some of the standard Android applications like the android Market (there's a small spinning circle that's actually integrated into the application window (as opposed to floating on top of it). Does anyone know how to create the smaller progress dialog (or can someone point me in the right direction)? Thanks!

    Read the article

  • Showing the ProgressDialog while opening the Website

    - by david
    I have to open a website say Facebook page, twitter page and You Tube page in order to share my post there. Now when I click to the item Facebook , it gets redirected to FB to share and same for Twitter and YouTube. I have to show them in my WebView and all this is done perfectly. What I want is to show the Progress Dialog after clicking on the Item till it gets redirected to the FB , Twitter or YouTube. I don know how to show the Progress Bar for redirecting to the Main Website. Can anyone Please help me put Here. Thanks, David Brown

    Read the article

  • How to show a ProgressDialog while changing from a activity to another activity?

    - by AndroidUser99
    i want to show a PD when my activity A starts another activity B. But in that onclick method, my A activity haves to do some work before start B, and B also haves to do some work because it haves to load a lot of data for the UI. I need a PD that is viewed by the user in all the process of the loading data of changin from activity A to B. ¿how can do it? i tryed storing a static ProgressDialog on MyApplication.java, and with these methods: public static void showProgressDialog(Context c) { pd = ProgressDialog.show(c, c.getResources().getString(R.string.app_name), c.getResources().getString(R.string.loading), true, false); } public static void dismissProgressDialog(){ pd.dismiss(); } but it doesn't works, it doesn't shows nothing, i dont know why how to achieve this by a easy way? i know that i can do it with async task, but that is too hard for me, i can't understand the code examples i am finding on this web and google code examples are welcome thanks

    Read the article

  • Android Progress Dialog not showing

    - by ilomambo
    This is the handler, in the main Thread, which shows and dismisses a progress dialog. public static final int SHOW = 0; public static final int DISMISS = 1; public Handler pdHandler = new Handler() { @Override public void handleMessage(Message msg) { Log.i(TAG, "+ handleMessage(msg:" + msg + ")"); switch(msg.what) { case SHOW: pd = ProgressDialog.show(LogViewer.this, "", getText(R.string.loading_msg), true); break; case DISMISS: if(pd != null) { pd.dismiss(); pd = null; } break; } } }; The message to show the progress is: pdHandler.sendMessage(pdHandler.obtainMessage(SHOW)); The message to dismiss it is: pdHandler.sendMessage(pdHandler.obtainMessage(DISMISS)); It works well when I call it before I start an AsyncTask, the AsyncTask onPostExecute() dismisses it. But when it runs within a runnable (runOnUiThread), the dialog does not show. Examining the pd variable on the debugger, it shows that is is created, it is running and it is visible, but in practice it is not visible. Any suggestion? UPDATE: I did the obvious test I should have done in the first place. I commented the DISMISS message. And the progress dialog did show up. It appeared too late, after the runnable was finished. I undestand now that the DISMISS message did dismiss the not-yet-visible ProgressDialog, that's why I did not see it. The question becomes now: I need the ProgressDialog to show BEFORE the runnable code is executed. And it is not so straight forward. My call hierarchy is like this: onScrollEventChanged --> runOnUiThread ( --> checkScrollLimits --> if need to scroll show ProgressDialog "Loading" get new data into table dismiss ProgressDIalog ) I tried something like this: onScrollEventChanged --> checkScrollLimits --> if need to scroll show ProgressDialog "Loading" --> runOnUiThread ( get new data into table dismiss ProgressDIalog ) But still the dismiss message got there before the ProgressDialog could show. According to Logcat there is a five second interval between the arrival of the SHOW message and the arrival of the DISMISS message. UPDATE II: I though I will use the isShowing() method of ProgressDIalog pd = ProgressDialog.show(...) while(!pd.isShowing()); But it does not help at all, it returns true even if the dialog is not showing yet.

    Read the article

  • ProgressDialog not working in external AsyncTask

    - by eric
    I'm beginning to think that to get a ProgressDialog to work the AsyncTask has to be an inner class within an Activity class. True? I have an activity the uses a database to manipulate information. If the database is populated all is well. If it is not populated then I need to download information from a website, populate the database, then access the populated database to complete the Views in onCreate. Problem is without some means to determine when the AsyncTask thread has finished populating the database, I get the following Force Close error message: Sorry! The application has stopped unexpectedly. I click on the Force Close button, the background AsyncTask thread continues to work, the database gets populated, and everything works ok. I need to get rid of that error message and need some help on how to do this. Here's some psuedo code: public class ViewStuff extends Activity { onCreate { if(database is populated) do_stuff else { FillDB task = null; if(task == null || task.getStatus().equals(AsyncTask.Status.FINISHED)) { task = new FillDB(context); task.execute(null); } } continue with onCreate using information from database to properly display } // end onCreate } // end class In a separate file: public class FillDB extends AsyncTask<Void, Void, Void> { private Context context; public FillDB (Context c) //pass the context in the constructor { context = c; } public void filldb () { doInBackground(); } @Override protected void onPreExecute() { ProgressDialog progressDialog = new ProgressDialog(context); //crashes with the following line progressDialog.show(context, "Working..", "Retrieving info"); } @Override protected Void doInBackground(Void... params) { // TODO Auto-generated method stub try etc etc etc } } What am I doing wrong?

    Read the article

  • Android ASync task ProgressDialog isn't showing until background thread finishes

    - by jackbot
    I've got an Android activity which grabs an RSS feed from a URL, and uses the SAX parser to stick each item from the XML into an array. This all works fine but, as expected, takes a bit of time, so I want to use AsyncActivity to do it in the background. My code is as follows: class AddTask extends AsyncTask<Void, Item, Void> { protected void onPreExecute() { pDialog = ProgressDialog.show(MyActivity.this,"Please wait...", "Retrieving data ...", true); } protected Void doInBackground(Void... unused) { items = parser.getItems(); for (Item it : items) { publishProgress(it); } return(null); } protected void onProgressUpdate(Item... item) { adapter.add(item[0]); } protected void onPostExecute(Void unused) { pDialog.dismiss(); } } Which I call in onCreate() with new AddTask().execute(); The line items = parser.getItems() works fine - items being the arraylist containing each item from the XML. The problem I'm facing is that on starting the activity, the ProgressDialog which i create in onPreExecute() isn't displayed until after the doInBackground() method has finished. i.e. I get a black screen, a long pause, then a completely populated list with the items in. Why is this happening? Why isn't the UI drawing, the ProgressDialog showing, the parser getting the items and incrementally adding them to the list, then the ProgressDialog dismissing?

    Read the article

  • startActivityForResult to an activity that only displays a progressdialog

    - by Alxandr
    I'm trying to make an activity that is asked for some result. This result is normally returned instantly (in the onCreate), however, sometimes it is nesesary to wait for some internet-content to download which causes the "loader"-activity to show. What I want is that the loader-activity don't display anything more than a progressdialog (and that you can still se the old activity calling the loader-activity in the background) and I'm wondering wheather or not this is possible. The code I'm using as of now is: //ListComicsActivity.java public class ListComicsActivity extends Activity { private static final int REQUEST_COMICS = 1; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_comics); Button button = (Button)findViewById(R.id.Button01); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intents.ACTION_GET_COMICS); startActivityForResult(intent, REQUEST_COMICS); } }); } /** Called when an activity called by using startActivityForResult finishes. */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Toast toast = Toast.makeText(this, "The activity finnished", Toast.LENGTH_SHORT); toast.show(); } } //LoaderActivity.java (answers to Intents.ACTION_GET_COMICS action-filter) public class LoaderActivity extends Activity { private Intent result = null; private ProgressDialog pg = null; private Runnable returner = new Runnable() { public void run() { if(pg != null) pg.dismiss(); LoaderActivity.this.setResult(Activity.RESULT_OK, result); LoaderActivity.this.finish(); } }; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String action = getIntent().getAction(); if(action.equals(Intents.ACTION_GET_COMICS)) { Runnable loader = new Runnable() { public void run() { WebProvider.DownloadComicList(); Intent intent = new Intent(); intent.setDataAndType(ComicContentProvider.COMIC_URI, "vnd.android.cursor.dir/vnd.mymir.comic"); returnResult(intent); } }; pg = ProgressDialog.show(this, "Downloading", "Please wait, retrieving data...."); Thread thread = new Thread(null, loader, "LoadComicList"); thread.start(); } else { setResult(Activity.RESULT_CANCELED); finish(); } } private void returnResult(Intent intent) { result = intent; runOnUiThread(returner); } }

    Read the article

  • android:black screen switching between activity

    - by 100rabh
    Hi, I am using below code from one of my activity to start another Intent viewIntent = new Intent (getApplicationContext (), landingPage.class); Bundle b = new Bundle (); b.putString ("ApplicationName", a_Bean.getApplicationName ()); if (landingPage.getInstanceCount () < 1) bp.landingPage_ProgressDialog = ProgressDialog.show (ViewAllApp.this, "Please wait...", "Retrieving data...", true, false); viewIntent.putExtras (b); viewIntent.addFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivityForResult (viewIntent,10); Thread background=new Thread(new Runnable() { public void run() { Progresshandler.sendMessage(handler.obtainMessage());//finishes progressDialog }}); background.start (); but after startactivity it shows a black screen & then displays new activity. Can I make progressdialog to be shown while the black screen is displayed??

    Read the article

  • progress dialog in main activity's onCreate not shown

    - by Mando
    After the splash screen, it takes about 6 sec to load onCreate contents in the Main activity. So I want to show a progress dialog while loading and here's what I did: import ... private ProgressDialog mainProgress; public void onCreate(Bundle davedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); mProgress = new ProgressDialog (Main.this); mProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgress.setMessage("Loading... please wait"); mProgress.setIndeterminate(false); mProgress.setMax(100); mProgress.setProgress(0); mProgress.show(); ---some code--- mProgress.setProgress(50); ---some code--- mProgress.setProgress(100); mProgress.dismiss(); } and it doesn't work... the screen stays black for 5-6 sec and then load the main layout. I dont know which part I did wrong :*(

    Read the article

  • android: showing a progress dialog

    - by mtmurdock
    I have looked at the Android API and other posts here on stackoverflow, but have not been able to figure this out. My app downloads files to the sd card. I would like to pop a "loading..." dialog while the file is downloading and then have it disappear when the download is finished. This is what i came up with using the android API: ProgressDialog pd = ProgressDialog.show(this,"","Loading. Please wait...",true); //download file pd.cancel(); however the dialog doesn't actually show. when i debug it, it claims that it is showing, but it is obviously not on the screen. what can i do?

    Read the article

  • Progress Dialog on open activity

    - by GeeXor
    hey guys, i've a problem with progress dialog on opening an activity (called activity 2 in example). The activity 2 has a lot of code to execute in this OnCreate event. final ProgressDialog myProgressDialog = ProgressDialog.show(MyApp.this,getString(R.string.lstAppWait), getString(R.string.lstAppLoading), true); new Thread() { public void run() { runOnUiThread(new Runnable() { @Override public void run() { showApps(); } }); myProgressDialog.dismiss(); } }.start(); The showApps function launch activity 2. if i execute this code on my button click event on activity 1, i see the progress, but she doesn't move and afeter i have a black screen during 2 or 3 seconds the time for android to show the activity. If i execute this code in the OnCreate of Activity2 and if i replace the showApps by the code on OnCreate, Activity1 freeze 2 seconds, i don't see the progress dialog, and freeze again 2 seconds on activity 2 before seeing the result. An idea ?

    Read the article

1 2 3 4 5  | Next Page >