Android Screen orientation, shake cellphone crashes the application
I am having search application, which loads data retreived from the webservice.
While application on create it shows progress dialog once its done with loading data it dismiss the progress dialog.
problem is while loading if i change the orientation of the phone it works fine it try to load activity again, but if i start shaking the cellphone while it is loading data application get crashed, any solution ???
Asked by: John938 | Posted: 20-01-2022
Answer 1
put
android:configChanges="keyboardHidden|orientation"
in you Activity xml tags.
and add these code to your activity.java
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
Answered by: Brooke411 | Posted: 21-02-2022
Similar questions
screen orientation - I want my android application to be only run in portrait mode?
I want my android application to be only run in portrait mode?
How can I do that?
android - Prevent Live Wallpaper orientation change when an application is opened and orientation is changed?
I'm having an orientation issue with a Live Wallpaper that I wrote. Basically the canvas will rotate depending on the application opened above it. I tested this and realized that the onSurfaceChanged() method is firing when I return to the home screen from a previously opened application who's orientation was changed.
I suppose a better question would be, why does my Live Wallpaper Surface Change when an ...
android - Get the view on orientation switch or when leaving application
I'm pretty new to this Android Programming. But I'm trying to make an application that receives content from a web-based server - this functionality works like a charm - finally.
But, for several days have I tried to find an answer to why my application want remember its view on orientation switching, when view is change to another activity or when leaving application.
I know there is something with the man...
android - On changing layout Orientation application crashes?
When i Change the layout Orientation application crashes in the simulator??
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_gravity="center_vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"><View android:layout_width="fill_parent" android:layout_height=...
orientation - Mandate Android Application to Start Portrait Only, BUT ability to rotate when running
I have an application that I want to start only in portrait, but once it has begun allow for configuration change. The content of the landscape mode is a map image that relates to the information on the portrait view.
bitmap - Android. How to determine screen orientation if application supports only portrait mode?
My Android application works only in portrait orientation. Landscape mode is disabled with
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT).
But i have a dialog with a signature view (custom view) and a user uses it for drawing his signature. It gives a bitmap as a result. I also have an ImageView for saved signature preview which displays the bitmap described above. A u...
opengl es - How do you properly handle device orientation from an android native only application?
The objective is to make a simple 2d arrow compass application like the one from the book iPhone 3D Programming here that rotates smoothly in response to orientation changes.
AndroidManifest...
android - How to stop a screen orientation change from resetting state in my application
When my Thread starts, I set an AtomicBoolean to true.
At the end, I reset it to false in the associated Handler.
When I change the screen orientation BEFORE the end of the Thread:
onSaveInstanceState() prints that this bool is TRUE
onPause() prints TRUE too.
-> Logical
The thread ends, I change again the orientation:
My Log.e "Bool" prints FALSE -> O...
orientation - Prevent restarting landscape Android application on lock
I am developing a game (sort of) which uses OpenGL and has background music. Application runs only in landscape mode.
Problem I have, happens when user locks screen. At that point onStop() is called, screen orientation is changed and soon after my Activity is restarted as a result of orientation change. This means OpenGL surface is recreated, music starts playing again and all sorts of other things. T...
Handle orientation change in Android tabbed application
This post is about a popular, well-discussed topic- Handle Screen Orientations. Even though it's much talked about, I could hardly draw a working solution for the app which forces me write here.
So, the app is basically made of tabs using TabHost. Each tab is an activity group. The app primarily fetches data from a web service using AsyncTask. Each child activity is attached to an AsyncTask which holds a U...
android - appWidget Orientation Code
I have code in an appwidget that I want to run when the phone's orientation changes on the home screen, ie like when the keyboard flips out. I have an image that I want to change in an imageview in my appwidget. I can't use different layouts linked to the orientation (ie "layout" and "layout-land") because I don't know the name of the image file until runtime, it is created at runtime. Is there anyway to trigger code to ru...
android - From WebView Errors to ImageView Cover-ups to Screen Orientation
It all started with a simple WebView within an Android app.
This view loads info from a public URL. Nothing unusual there.
However ... if there should be a network interruption, you can easily end up with an error displayed prominently in the WebView.
Well, that's no good, right? So I searched the docs and elsewhere for a way to suppress this, or trap it ... and fou...
Android TimePicker hour field disappears after orientation change
I am using a TimePicker under API 1.5 and when the orientation is changed on my device (a stock G1 running 1.6 - though NOT on the 1.5/1.6 emulator), the hour field goes blank. It still remembers the hour, it just doesn't show it. Is there any workaround for this?
The same problem was described by someone else here:
Android Bluetooth crashes after orientation change
My code is based on the BluetoothChat sample from the API. I connect to another device just fine and I can read and write to the connection no problem. But then if I turn the device the orientation of the UI changes automatically. After this, if I try to write to the Bluetooth connection, my application crashes!
It seems weird that the orientation of the screen somehow affects the Bluetooth. I am new to Android, an...
android - How to change orientation of xml "layout" area in Eclipse
The xml files that contains the Activity layouts can be rendered by Eclipse.
How do I get that Eclipse screen area to have vertical orientation, not horizontal (inside Eclipse - it correctly shows as vertical in the emulator)?
Peter
Android - Forced locale reset on orientation changes
I try to force the locale in my app to one the user specified. As this may be used to demonstrations, I want to change the language/locale in the app and not anytime for the whole device.
I looked around SO and tried to use every hint I found here. The result: I can restart my test activity with the new language, but if I change the orientation, the locale will always be reseted to the device one.
I
How can the landscape screen orientation be restricted in android?
How can the landscape screen orientation be restricted in android?
Problem saving WebView scroll position during orientation change in Android 2.1
I have a problem preserving the current scroll position of content loaded in Android's WebView control during orientation changes. The issue currently exist only in Android 2.1 and Android 2.1 Update 1
The code that I use is based on the default Browser application and looks like this:
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mWebView = n...
android - How to detect orientation change in home screen widget?
I am writing a home screen widget and want to update the home screen widget when the device orientation changes from portrait to landscape or the other way. How can I make it?
Currently, I tried to reigster to CONFIGURATION_CHANGED action like the code below, but the Android didn't allow me to do that by saying "IntentReceiver components are not allowed to register to receive intents". Can someone help me? Thanks.
android - Gracefully handling screen orientation change during activity start
I'm trying to find a way to properly handle setting up an activity where its orientation is determined from data in the intent that launched it. This is for a game where the user can choose levels, some of which are int portrait orientation and some are landscape orientation. The problem I'm facing is that setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) doesn't take effect until the activity...
Still can't find your answer? Check out these communities...
Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android