Android - Indeterminate ProgressBar - android

I am using the code from this website (http://www.helloandroid.com/tutorials/using-threads-and-progressdialog) in my App.
It is somewhat working, but not entirely:
When I press Button X, a method is called, and while it is working, the progress bar is shown. After the method is done, another activity is started. So far everything is working fine. But when I press the "BACK" button on my phone, the progress bar is shown again, and appears to be doing nothing.
What can I do to prevent that?

Dismiss the progress bar at the same time that you start the second activity.

Related

Activity with Theme.Dialog can be dismissed when user touches anywhere on screen, but not with Theme.panel

I'm trying to display an activity with a button that covers a portion of the screen similar to a dialog.
This was almost working as I wanted it by using #android:style/android:Theme.Holo.Panel. It wasn't quite what I wanted however as I want the background to be dimmed with the activity is displayed. So I switched to this style instead: #android:style/android:Theme.Holo.Dialog.NoActionBar.
Now this looks like I want it and the background is dimmed. BUT the problem with this is if the user touches anywhere on the screen apart from the dialog then the activity gets dismissed. This does't happen with the Panel theme, the user can only dismiss it by pressing on the button.
How can I prevent the activity from being dismissed on any touch event with the Theme.Holo.Dialog?
Have you tried this.setFinishOnTouchOutside(false); ?
This being your activity.

Android indeterminate progress bar between activities

How to get an indeterminate progress bar between two activities, I mean, I'm in activity A, show the progress bar, while the progress bar is showing, a new activity B is started and in this activity B I want to close the progress bar. Thank you.
You can't do it that way. An Activity is what holds everything on the screen for your application. If you are "inbetween" two activities then you have no way to control what is on the screen.
You need to put the progress bar into ActivityB, and make it visible by default, then when you are done loading your data make it invisible with
progressBar.setVisibility(View.GONE);
If your ActivityB is taking a long time to load before showing any Views then it is an indication that you are doing some loading work on the Main thread, that you should isntead be doing in the background, and updating the Views once loading is complete.
There is no reason to do so. Starting a new activity is a very fast process, almost instant (unless you onPause method takes very long), so the progress bar will never be shown.
That being said, there is a hacky way to get a progress bar to be shown between activities
you call ProgressActivity(that you create) from ActivityA then after waiting for some time (delayed runnable) you call ActivityB. This does nothing constructive and should not be used.

Custom ProgressBar not spinning, when open from onResume()

I have a custom progress bar in my app. When I open my app, this Custom ProgressBar works well, but in some situations where my app calls itself, the onCreate() event does not called.
The app starts from an onResume() event. I have created a function to open the progress bar that is called in the onResume() event. The problem is that the custom Progress Bar gets opened but does not start SPINNING, and it is dismissed after the task is completed. It therefor appears as if the application is hanging.
Are there any solution for this?

Android Navigation bar appearing when in full screen

In my application, I have set it up in the XML so it is in full screen using
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Now this works fine when the app opens, however if while using the app, I use the home button to back out of the app, and then open it again, when it opens, a black navigation bar will appear for a second or two before disappearing. This does not occur if I exit the app using the back button, just the home button.
Does anyone know why this happens? I have tried doing it from code instead using
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
However, what this does is removes the title bar, but the black bar is there at the top, just nothing is in it.
I.e. this bar
I tried combining the code, by putting the full screen line of code in the XML and also adding the code I showed above into the app, but same thing happens. If I back out of the app with home button and enter it again, that black bar will appear for two seconds temporarily pushing the app and its contents down before righting itself again.
How do I go about fixing this? I have been trying loads of different solutions, but nothing seems to work.
Thanks in advance
Seems to a bug with Android OS. Only way to fix it is go to device, settings animation, and disable animations.
try to remove animation by setting->brightness->animation
set no animation there

Is there a way to onCreateOptionsMenus() continue "listening" while a Progress Dialog is showing?

The Title is almost the entire question but i'll complement it with some things :
-(1) I have a AsyncTask for get some data from Internet
-(2) I have a AsyncTask for display a Progress Dialog
Before call (1) , I execute (2) dialog.show() and when task (2) ends I call dialog.dimiss(). All is doing right , but while the Progress Bar is showing the Menu Button stay unresponsiveness, ie , nothing happens...
I would like to know if it is the default behavior or i missing something ?
I'm looking for it and did found anything that clear me about it..
Aprecciate any advice
You mean to say that while the dialog is showing, pressing the hard menu button does not bring up the menu. Did I get it right?
If so, then I see the same behavior as you. But according to this:
For example, when a dialog is open,
the Menu key reveals the options menu
defined for the Activity and the
volume keys modify the audio stream
used by the Activity.
So I would expect that the menu button should still work even if the dialog is showing, but based on my experience, it does not.
After the dialog is dismissed, the menu button should work again.
onCreateOptionsMenu is meant to prepare the dialog. Once it is shown and in use it is no longer being prepared and thus use of the dialog is then handled in onOptionsItemSelected.

Categories

Resources