Is there a standard pattern for handling a running AsyncTask with screen rotation? My AsyncTask runs for about 10 seconds. I could call AsyncTask.cancel in the Activity's onDestroy method and restart the task in onCreate but that would waste cycles, bandwidth, and user time. I'm guessing there is a better way.
I'm trying to figure out the correct way to create an AsyncTask to retrieve some data from the internet and then to take that data and bundle it up in an Intent and pass it to a new activity(A list display). So in the first activity I just have an EditText and Button. In the event of an OnClick the task should be called and when it is finished the data should be bundled inside an Intent and passed to the next Activity. The problem is when I take the results from onPostExecute and set them to an instance variable of the main activity, that instance variable is still null when the task is complete. Here is the barebones version of the code:
When I debug the application I see onPostExecute does contain a valid PlacesList full of results, so why is the instance variable places set to null after the task is executed? I am going about "returning data" from an AsyncTask incorrectly?
I have an activity which I have defined to keep in portrait position.
However I would still like to change things (slightly) when the screen is rotated, what is the best way of doing this? I notice onConfigurationChanged is still called, but this still reports portrait mode.
I want to keep the notification bar etc in the same position if possible.
I'd like rotate the screen to put it upside down. Can I do that with android API? I was told by some friends that there are APIs to rotate the screen by 90 degree but I can't find a way to rotate the screen by 180 degree (upside down).
When I change the orientation of my screen in Android, an OnItemSelectedListener from a Spinner is called. It's not just the emulator, it also happens on a physical phone. How can I stop this from occurring?
I've got an app that I don't want to auto-rotate. Currently, I've got it setup so that it is always in portrait mode. However, I'd like to add a setting to my preferences where the user can choose either portrait or landscape mode. Is there a way to force screen rotation? Or, could I perhaps make two different layout XML files, one for portrait and one for landscape, and programmatically choose which to use?
I have come across some very unexpected (and incredibly frustrating) functionality while trying to restore the state of a list of CheckBoxes after a screen rotation. I figured I first would try to give a textual explanation without the code, in case someone is able to determine a solution without all the gory details. If anyone needs more details I can post the code.
I have a scrolling list of complex Views that contain CheckBoxes. I have been unsuccessful in restoring the state of these check boxes after a screen rotation. I have implemented onSaveInstanceState and have successfully transfered the list of selected check boxes to the onCreate method. This is handled by passing a long of database ids to the Bundle.
In onCreate() I check the Bundle for the array of ids. If the array is there I use it to determine which check boxes to check when the list is being built. I have created a number of test methods and have confirmed that the check boxes are being set correctly, based on the id array. As a last check I am checking the states of all check boxes at the very end of onCreate(). Everything looks good... unless I rotate the screen.
When I rotate the screen, one of two things happens: 1) If any number of the check boxes are selected, except for the last one, all check boxes are off after a rotation. 2) If the last check box is checked before rotation, then all check boxes are checked after rotation.
Like I said, I check the state of the boxes at the very end of my onCreate(). The thing is, the state of the boxes at the end of onCreate is correct based on what I selected before the rotation. However, the state of the boxes on the screen does not reflect this.
In addition, I have implemented each check box's setOnCheckChangedListener() and I have confirmed that my check boxes' state's are being altered after my onCreate method returns.
Why would the state of my check boxes change after my onCreate method returns?
I have been trying to degub this for a couple days now. After I found that my check boxes were apparently changing somewhere outside my own code I figured it was time to ask around.
I am working on a home screen widget. I hope this widget can support auto rotation. For example, if the phone is in portrait mode, I want this home screen widget to be 2 cell * 2 cell on the home screen; if the phone is in landscape mode, I want this home screen widget changes be 3 cell * 1 cell on the home screen.
My 2.1 rom only went into landscape mode when I turned the phone counter-clockwise. I have found that since updating to 2.2, the screen will go into landscape if I go either direction! I really liked the old one way landscape, and I wonder if this was intended, or just the result of an unfished leak...
I have an android application that I want to always be running in landscape mode.
I have the following code implemented to keep the app in landscape mode all the time:
inside my activity in the Application Manifest android:screenOrientation="landscape"
This seems to launch and keep the application in landscape view for the whole duration of the application. Perfect!
However, if I have the app running on my HTC Aria (Android 2.1) and the phone locks, if I unlock the phone, I see the application for probably half a second and it's in portrait orientation and then quickly switches back to landscape mode. It is quite frustrating because all of my views are jumbled around and it looks unprofessional as you can imagine. This happens in both the emulator and on my real phone.
Does anyone know how to stop the application from temporarily rotating when the phone is unlocked?
I have tried overriding onConfigurationChanged() but with no success.
I have also tried putting setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); into the onResume() but the app still shows as the incorrect orientation for a split second when the phone is unlocked.
Does anyone know of a ROM that is Sense based and also includes a Home Screen Rotation ability?I know that LP can do this, but I value the Sense widgets more than resorting to LP.unless every single Sense widget could be replaced for under $15 total.
Running BB1.1, but it doesn't allow the screen to rotate automatically, even though that option is turned on in the settings. I noticed Ultimate 3.7 does allow this, what other ROMs allow it? It's a minor feature, but one I like to have....
I have been trying to keep the context menu when doing a long press / Click to stay on screen when the screen is rotated.Searching around the net, the main answers found are not the best such as add configChanges into the android manifest or use the onRetainNonConfigurationInstance which is depreciated .
Currently I am handling my dialog boxes when on screen and a rotation occurs via savedInstanceState by having my own method to show them again by using a variable to be saved into the bundle and then retrieved.
However the context menu is slightly harder to do as it is registered against the listview I have and this links it together so it knows which row has been selected
I do also have a onitemlongclick method which works along side the contextmenu so I should be able to get the row information from there but it is then how to call it all back afterwards
I was working on implementing a more advanced list view then the standard one they teach you in basic tutorials, and I did find a great tutorial explaining how to create your own Adapter and such not. http://www.softwarepassion.com/android-series-custom-listview-items-a...
I do have a working version of the tutorial and I am currently in the process of changing the list to suit my needs, but there are a few issues I am stumped on. If your run the tutorial code it creates a little progress dialog saying that it is retrieving data. In my application it is going to be fetching data from the internet and storing it in an ArrayList of custom objects. However if I where to rotate the screen the progress dialog pops up again, I have no clue on how to set it up so that when it rotates that it doesn't recreate everything and re-fetch the data and process it again.
My Desire; which i have had problem free for 3 months; has just developed a problem with the screen rotation. Initially it wouldn't rotate so i checked that it was set to automatically rotate in the screen and display menu which it was .
I then tried to recalibrate the screen which kind of worked in that it now allows the screen to rotate to landscape if held sideways, but when i put it the right way up, the screen stays landscape.
I have Swype which i thought might be interfering so i removed the program and rebooted but still nothing.
I feel foolish as all get-out, but I have managed to put the screen on my Eris into an animated rotation mode. I.e. instead of snapping from horizontal to vertical, it rocks from side to side for a annoying period of time. I can't find the setting under 'display'
Since the 2.2 update my screen auto rotation is horrible. When I want it upright, it goes sideways. WHen I hold the phone sideways, it flips the other way. Apps that I open seem to always start out sideways even when the phone is upright. I turn it around, nothing happens. If it does rotate back, it is so delayed you think it is not working. It never seems to be the direction I want it, getting very frustrating and annoying to keep flipping the damn phone around all the time to try to get it right. I sure hope the new FRG22 update, if it ever comes, can fix this problem. So far, 2.2, besides flash, has been a big disappointment for me.
I am creating a layout dynamically when the activity first starts, the problem is when the screen is rotated it is hitting the database again to create the layout. How can I save the layout so it isn't recreated each time the screen orientation is changed?