Android : Way To Handle Device Rotation?
Jul 9, 2010I want to disable the view change on device rotation for the time being. Its giving foreclose error when i rotate the device and starts all over again.
View 3 RepliesI want to disable the view change on device rotation for the time being. Its giving foreclose error when i rotate the device and starts all over again.
View 3 RepliesHow to save my instance state or how to deal with my activity getting destroyed during screen rotation.
There seem to be a lot of possibilities but I haven't figured out which one works best for retrieving results of an AsyncTask.
I have some AsyncTasks that are simply started again and call the isFinishing() method of the activity and if the activity is finishing they wont update anything.
The problem is that I have one Task that does a request to a web service that can fail or succeed and restarting the task would result in a financial loss for the user.
How would you solve this? What are the advantages or disadvantages of the possible solutions?
How can i get the rotation of the device in the four main orientations? and is there a corresponding event that i can capture?
also, is it possible to disable this rotation for my app?
Can any one tell me how to handle the device back key navigation? Because i want to use this action as coming back to my application screen. Here i used only one Activity for building all screens.
View 2 Replies View RelatedI read a lot about handling rotation in android applications, but I still have so many questions and need to much to understand. Let me explain my problem or implementation, that I'm using now in my application. If an activity will be opened, a get request will be sent to server. This request will be executed in a Thread (new Thread(...)) and if request was completed, activity's ui will be refreshed. But what should I do, if the user rotate his device?
View 3 Replies View RelatedBeen an increasing amount of talk lately about Froyo (2.2) and how it will have flash and all that jazz. I use a non-rooted, standard ROM Droid, and I'm wondering how well it will handle all of these improvements. I assume the newer android devices with their gHz processors will do fine, but how do you think us Droid users will fair? And don't just say it can handle it. I know it will work, but how well is my question?
View 16 Replies View RelatedI have a couple of apps currently in the marketplace and they follow the Android design guidelines as close as possible. One of the people who purchased my app says he's using it on a device without a 'menu' button. The device is a Eken M0002, a 7" tablet running Android 1.6 I know that tablets are not officially supported yet. My question is, has anyone started dealing with this potential issue, and if so how?
View 5 Replies View RelatedI have a problem with rotation, during my ListActivity is loading data from the network. To do it I use a background thread which recovers data and put them inside an ArrayList. While this thread works, there is Progress dialog activated in foreground. For the rotation I use the method with onRetainNonConfigurationInstance() to save my ArrayList's state. After android calls this method, I call dismiss() on the progress dialog on onStop(). Then the activity is created as new with onCreate(), but it use the getLastNonConfigurationInstance() to recover the ArrayList's state. Now, my problem. If I rotate from portrait to lanscape when the download is terminated and I see the data in portrait yet, everything is ok. If I rotate during progress dialog is showing I have two cases: 1- onRetainNonConfigurationInstance() saves the arraylist fully recovered, the thread terminates and everything is ok. 2- onRetainNonConfigurationInstance() saves the arraylist empty, i think the download isn't finished yet. The onCreate is called and my list is empty, the thread terminates, but i don't see anything in my list. If I am in this case and I still rotate from landscape to portrait now I can see my list full with all the data. Why? Where am I wrong?
View 7 Replies View Relatedhow to rotate fragment in android 3.0.I have an activity in which there is listfragment and fragment.on click of the item in list i want to apply rotation for the fragment.I have tried with below given code:
ObjectAnimator.ofFloat(getView(), "rotationY", 0, 360).setDuration(500).start();
This code works well witn listview in listfragment but when i used the same for fragment rotation it throws exception.
I've got an app where I don't want the screen to rotate when they rotate their device, I need to keep the app in portrait mode all the time. How do I do this?
View 2 Replies View RelatedHow should I handle an active ProgressDialog when the screen is rotated? Perhaps I should cancel the dialog in onDestroy and restart it in response to a SavedInstanceState flag?
I'm getting an exception and the following message in logcat:
CODE:..............
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.
View 1 Replies View RelatedIn my Android app I have 2 layouts, one for portrait and one for landscape.
In both layouts I have a TextView that the user can change by clicking on, by default it reads 'ON'
If the user presses it then it changes to 'OFF' All well and good.
However if it's set to OFF and the screen is rotated the text view resets to ON. How can I stop this from happening?
I need to calculate a rotation vector out of the data i get from Sensor.TYPE_ORIENTATION. The sensor data is defined like this: the values have to be recalculated to become a correct 3d position: values[0]: Azimuth, angle between the magnetic north direction and the Y axis, around the Z axis (0 to 359). 0=North, 90=East, 180=South, 270=West values[1]: Pitch, rotation around X axis (-180 to 180), with positive values when the z-axis moves toward the y-axis. values[2]: Roll, rotation around Y axis (-90 to 90), with positive values when the x-axis moves away from the z-axis need all three values like the Z axis value (from 0 to 360 degree). I tried a lot but cant figure out how to do this :/ So i bet there is a simple solution how to recall the values of sensor.TYPE_ORIENTATION to make them a 3d rotation vector, but i just dont know how to do it. If you know the answer please tell me. Code...
View 3 Replies View RelatedIn the api demo, there is an example for how to rotate a cube, but it can only rotate about X axis or Y axis, without Z-Axis Rotation. So how to perform 3D Rotation?
View 5 Replies View RelatedI spend two weeks now trying to get this working with no success. Here is what I want to do: I have several geo points around the user and his phone. I want to display this point overlaying them on the input from the camera (kind of standard AR (Augmented Reality) app). Part of my requirements are that the user can use the phone in either landscape or portrait mode.My plan was like this.
1. Register for Sensor.TYPE_ACCELEROMETER, Sensor.TYPE_MAGNETIC_FIELD 2. Pass the result to Sensor Manager.getRotationMatrix(), getting back the R matrix that should be telling me how to translate points from the Phone coordinate system (defined here: http://developer.android.com/reference/android/hardware/SensorEvent.html) to World coordinate system (x -> East, y -> North, z -> Sky) 3. I want to translate points from World to Phone so I take the inverse of R (I'm using Matrix.invertM()) to get R_In 4. Using the GPS I translate the geo points I want to display on the camera to points in the World coordinate system and then I run them through the R_In matrix to get their coordinates in the Phone system. 5. Draw the points in the screen only if the have (phone coordinates) z < 0 and x and y such that they are visible. This is my grand plan... however I have problems quite early (2). I do get the R matrix back and it looks good when I align the phone to the world coordinate system ( I get the identity matrix ). However when I try to translate an imaginary point from the Phone coordinate system say (0, 1, 0) to the World coordinate system I don't get the numbers I expect.
My application while compiled in 1.5 works fine. I had some memory issues w/ 1.6 due to image size, which was strange b/c the image size increased when taking photos by taking a picture w/ surfaceholder/imagecapture callback. I seem to have fixed re-displaying those images by resizing them using a bitmapfactory matrix. But my camera is now rotating everything 90 degrees. It appears that my Override of surfaceChanged does nothing, which is where I was setting rotation at 90 (I can't remember why, it was 10 months ago!). I have tried at rotating the camera parameters paramters at 90 degrees, 0 degrees.
View 2 Replies View RelatedStep #1: Make it a static inner class
Step #2: Manually associate your activity with the task in its constructor
Step #3: Return the task object from onRetainNonConfigurationInstance() of your activity
Step #4: In onCreate() of your activity, check getLastNonConfigurationInstance(), and if it is not null, associate your new activity instance with the task via a setter
Step #5: Use the activity within onPostExecute()
does anybody knows how to launch a new activity with rotation animation.That I would like to know if there is a way to do the same but instead of image, i will be activity (whith new layout).
View 1 Replies View RelatedI have a apk file, where i dont have the source for it.
When i run the apk, it automatically rotates the screen,
/WindowManager( 879): Setting rotation to 1, animFlags=0 I/WindowManager( 879): Config changed: { scale=1.0 imsi=0/0 locale=en_US touch=1 key=2/1/2 nav=3 orien=1 }
then after closing the application or coming out from the application,
I/WindowManager( 879): Setting rotation to 0, animFlags=0 I/WindowManager( 879): Config changed: { scale=1.0 imsi=0/0 locale=en_US touch=1 key=2/1/2 nav=3 orien=2 }
how to disable the rotation.
Here's a crashlog. It happened on n1 after a rotation. Looks like the swap function is called with a wrong arg. Log ...
View 2 Replies View RelatedI am rotating a view using rotateAnimation with this code new RotateAnimation(0, 360, w / 2, h / 2); I want to rotate this view infinitely, so i put setRepeatCount(RotateAnimation.INFINITE);
But the problem is after every one complete rotation, its stopping and starting again, means by default rotateAnimation have AccelerateDecelerateInterpolator(). I feel because of this. So if i put setInterpolator(null), its throwing null pointer exception. How to solve this.
I want to rotate my view without any lag.
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.
Is there any way to make autorotation work in both ways: both clockwise and counter clockwise? It's a pain when reading a book that scrolls with volume keys (HTC Hero).
View 2 Replies View RelatedI'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).
View 3 Replies View RelatedHow to add rotation effect when change mode portrait to landscape? I want to make it smooth.
View 2 Replies View RelatedI'm playing around with android, and I'm creating a simple twitter app to test what I've learned so far. But I've run into a problem that I don't understand. I created a thread to fetch the tweets, no problems there, but then added a ProgressDialog to show when that thread was running. Doing so caused a very unusual behavior. If the user rotates from Vertical orientation, to horizontal orientation, program behaves as expected, no problems, but if he then rotates back, the program crashes saying a window leaked.
The problem only happens on a horizontal to vertical layout switch. I know of the issues of if you try to rotate while the dialog box is running, but I've made sure that the dialog box has finished running and dismissed before rotating and it will still crash. Heres my code:
package com.onesmartpuppy.puppytweet;
import java.util.ArrayList;
import com.github.droidfu.widgets.WebImageView;
import winterwell.jtwitter.Twitter;
import winterwell.jtwitter.Twitter.Status;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Context;...............
How can implement video rotation during playback (or before starting playing)? I tried: private SurfaceView video = null; video = new SurfaceView(); video.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); video.getHolder().lockCanvas().rotate(90);
it gives me error: 12-08 15:39:54.551: WARN/System.err(17811): android.view.SurfaceHolder $BadSurfaceTypeException: Surface type is SURFACE_TYPE_PUSH_BUFFERS.
If somebody could give me simple example or just references how to establish it, that would be great. Maybe Android does not support video rotation at all. Could somebody confirm that?
The title about sums it up. I'm on Froyo, and would really like an app to stop the damn screen rotating clockwise to the landscape orientation. If there's an option to do it I haven't found it, and if there isn't I may have to find the nearest google employee and yell at him till he fixes it.
I'm not looking for something to lock screen rotation using a toggle, I still want it to rotate anticlockwise.
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?
View 1 Replies View Related