Android :: Orientation Change Crash In Tab Activity With List Activity

Jan 21, 2010

When views with different type have same id and screen orientation changes,

either java.lang.ClassCastException: android.view.AbsSavedState$1 or java.lang.IllegalArgumentException: Wrong state class -- expecting View State will occur. (depends on the view's order)

Because View.dispatchRestoreInstanceState() checks id only.

You may wonder why anyone would make views with different type to have same id.

But it can happen when you use tab activity.

Imagine you have tab activity with two children activity.

Tab1 is ListActivity and Tab2 is ExpandableListActivity.

Both activity have id of "@android:id/list" but the type of view is different.

This means we cannot use ListActivity & ExpandableListActivit at the same in one tab activity.

Android :: Orientation change crash in tab activity with list activity


Android :: Orientation Change - Dialog Above Activity With Fixed Orientation

May 14, 2009

I have created an activity for my game which handles all orientation changes by itself and has a fixed "portrait" layout. Actually it uses the accelerometer and is rendered using 2D canvas methods. If the level has been completed I show up a highscore dialog in which the user can enter his name. The dialog is floating above the underlying level screen which gets blurred out nicely. This generally works.

Problem is that the dialog does not get rotated if the orientation of the phone changes. So even if the keyboard is exposed the dialog is shown in portrait mode instead of landscape. I have tried to use an activity with dialog theme instead but the behavior didn't change. After several tries it seems that I have found the reason for this: Once there's an activity with fixed orientation in the activity stack then all subsequent activities keep this orientation, too. They will not react on orientation changes anymore (e.g. if the keyboard gets exposed).

After upgrading to 1.5 SDK the described behavior changed a little bit. Now at subactivities indead react on orientation changes like expected. However, the need to have an opaque background! That means that neither dialogs nor activities with dialog theme will work. Those will stick with the orientation of the underlaying activity. So my workaround is to first start a sub-activity with an opaque black background. This activity then shows my highscore dialog on top. It looks quite okay but I wonder if there's a better solution? Is it possible to show a dialog above a fixed portrait or landscape activity which automatically adapts to orientation changes?

View 3 Replies View Related

Android :: Change Intent Bundle Data Before Activity Recreated After Orientation Change

Jul 30, 2009

I have a notification that starts my activity and passes a messages using the intent's putExtra() function. The message is then displayed to the user in the activity's onCreate function. When the application is restarted due to a orientation change, the message is shown again as it is still in the intent's bundled data.
How can I remove the extra data?

I tried the following:

Bundle bundle = getIntent().getExtras();
if (bundle.getBoolean("showMessage")) {
// ... show message that is in bundle.getString("message")
// remove message
bundle.remove("showMessage");
}

But the message will still be shown after the orientation changed, seems like the intent used is not the one I changed, but the original one. The only workaround I found is to save the showMessage additionally in onSaveInstanceState(). Is there another way? Or is this the way to go?

View 2 Replies View Related

Android :: Maintaining State Of Activity On Orientation Change

May 6, 2010

I m currently working on landscape mode for android app in which i want to know how to maintain the state of the activity and views displayed on orientation change i.e from portrait mode to landscape mode ?

View 3 Replies View Related

Android :: Activity Being Killed - OnDestroy - On Orientation Change

Apr 5, 2010

I am working on a MVC implementation for Android (to be subsequently hosted on SF and/or GC).

It works like this:

Activity (View) <=> Application (Controller) <=> Data (Model) <=> Persistence (DB/Network etc)

The scenario is:

1. Activity launch (main/launcher)

2. Notifies Application about performing a data transaction

3. Upon receipt of data response, controller devices which Activity to launch (or update existing)

4. Application has overridden the method onConfigurationChange

Problem: When the orientation is changed, the Application is notified about onConfigurationChange but:

a) The "current" activity is Destroyed and recreated -- which is fine to some extent b) The new instance which is created is automatically => onCreate, onPause, onStop, onDestroy.... now that's catastrophic.

View 4 Replies View Related

Android :: Prevent Rotation/change Of Orientation In Certain Tab/activity

Sep 11, 2010

My MainActivity (the one that is started by the android application) is a TabActivity which contains several tabs (which are implemented as activities as well). In a certain tab/activity I want to prevent the change of orientation/rotation when the phone is turned. What is the easiest way to achieve this?

View 2 Replies View Related

Android :: Background Activity For Map Started Again When Orientation Change

Apr 6, 2010

i've developed an android app that's fetches an xml file and displays this data via several markers on the map. This works fine so far. The problem right now is that when i switch the orientation of the phone (portrait->landscape or vice versa) the markers disappear for a small moment, the xml processing is started again and then they reappear. Is there a way to prevent this re-loading of the file? It only takes about 2-3 seconds.

View 2 Replies View Related

Android :: Handling Screen Orientation Change During Activity Start

Mar 12, 2010

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 is fully loaded. This is a problem for me because I do some loading and image processing during startup, which I'd like to only have to do once.

Currently, if the user chose a landscape level:

the activity starts onCreate(), defaulting to portrait discovers from analysing its launching Intent that it should be in landscape orientation continues regardless all the way to onResume(), loading information and performing other setup tasks at this point setRequestedOrientation kicks in so the application runs through onPause() to onDestroy() it then again starts up from onCreate() and runs to onResume() repeating the setup from earlier

Is there a way to avoid that and have it not perform the loading twice? For example, ideally, the activity would know before even onCreate was called whether it should be landscape or portrait depending on some property of the launching intent, but unless I've missed something that isn't possible. I've managed to hack together a way to avoid repeating the loading by checking a boolean before the time-consuming loading steps, but that doesn't seem like the right way of doing it. I imagine I could override onSaveInstanceState, but that would require a lot of additional coding. Is there a simple way to do this?

Solution:

As per Daniel's answer, this was actually quite easy to fix. I just needed to make a few small changes. In my 'menu' Activity, where the player would choose which level to play, I just had to add an if/else check to choose which class would be started by my Intent. This was done with a simple int representing portrait or landscape, determined when the player selected a level. I then created a second class extending my 'GameLogic' class; this is the class which contained most of the code for the game itself, rather than the menus, instructions, etc.

public class GameLandscape extends GameLogic{}

Literally that simple and completely empty. That way it inherited all the code from my previous activity where I had already coded it to handle things differently depending on the orientation. Lastly I just had to add a line to the manifest stating that GameLandscape would always run in landscape, and GameLogic would always run in portrait.

View 2 Replies View Related

Android :: Handle Screen Orientation Changes With An Activity Started Within A Tab's Activity

Nov 2, 2010

I have a TabActivity, and each Tab corresponds to its own Activity. In one of them, in the onCreate method, I use startActivityForResult to show a dialog (specifically, Bump's BumpAPI activity).

code:...............

The problem is that when the screen orientation changes, it tries to create the tab's activity again which makes another BumpAPI dialog, resulting in multiple stacked on top of each other. Do I have a hook into the started activity to cancel the previous one when the orientation changes?

A workaround seems to be to add a button that when clicked, starts the second activity, but that adds an unnecessary step.

Also, I can't fix the screen orientation for the entire tabActivity because some of them require typing and users may want to use their physical keyboards.

View 1 Replies View Related

Android :: Show AlertDialog On Activity Start - But Not On Screen Orientation Change

Aug 13, 2010

It seems when screen orientation changes, the activity's onCreate() method is called. In my onCreate() method, I have an AlertDialog which pops up when the activity is called. The problem is when I switch the screen sideways, the popup is displayed again. How can I avoid this?

View 1 Replies View Related

Android :: Unbind Remote Service In OnDestroy Of Activity On Screen Orientation Change

Nov 24, 2010

In onCreate method of Activity, it binds to a remote service and makes use of AIDL intefaces. Is it required to unbind from the remote service when onDestroy is called on screen orientation change.?

If the activity un-bounded from the remote service in onDestroy and if no other contexts are bound to remote service, is remote service likely to get stopped losing the state that it maintains.?

View 1 Replies View Related

Android :: Screen Flip Doesn't Trigger An Orientation Change And Activity Destruction/recreation

Aug 29, 2010

I'm testing an app on a Droid. It's a kind of card matching game. I'd like to keep the cards physically located in the same place on the screen regardless of a screen rotation. For example, I can put my thumb on a card, rotate the phone any way I please and the card stays fixed under my thumb. However, the orientation of the content of the card will change to match the current phone rotation. I handle this by transforming the card grid in onCreate. This works fine for 90 degree rotations, but if I do a fast 180 degree flip from one landscape mode to another the screen simply flips and the Activity is NOT destroyed and recreated.

This seems contrary to the documentation:

http://developer.android.com/reference/android/R.attr.html#configChanges

"public static final int configChanges Since: API Level 1

Specify one or more configuration changes that the activity will handle itself. If not specified, the activity will be restarted if any of these configuration changes happen in the system. Otherwise, the activity will remain running and its Activity.onConfigurationChanged method called with the new configuration. "

I am NOT specifying any configChanges in my AndroidManifest.xml file, so it seems that the activity SHOULD be destroyed and recreated. Why isn't it? Is there some way I specify that it should be destroy/ recreated?

View 7 Replies View Related

Android :: Can Update A List View In One Activity While Im In Another Activity

Oct 4, 2010

I currently have a tab layout with 2 tabs, one tab with a list view and one with the option make strings so I can add them in the list view. Both tabs have their own activity because this made the code much more structured, and I dont have to repeat my self later.

Lets say im in the tab that offer me to create an string, and i press the update list button, how do I update the list view without startActivity()? If i use startActivity(), it starts List.java, and instead of displaying the list in the list view tab, it takes full screen, which defies the purpose of the tab view. In other words, the startActivity() steals the focus from the tab view of the list, and sends it fulscreen.

I want to update the activity in my list view tab, without starting a new activity that goes to fullscreen, and doesnt update the one in the tab.

View 2 Replies View Related

Android :: Change Screen Orientation When Call Is Ongoing / Phone Process Will Crash

Jun 15, 2009

I found if change screen orientation continouously when a call is ongoing, that is, portrait -> landscape -> portrait- >landscape.

View 3 Replies View Related

Android :: Getting Crash When Exiting Activity?

Sep 4, 2009

I am experiencing a crash in my app when I quit (via the back button) out of my Activity. So far as I can tell this is happening in the Android codebase and not mine, but I'm not completely convinced of that.

AndroidRuntime E Uncaught handler: thread main exiting due to uncaught exception
AndroidRuntime E java.lang.RuntimeException: Unable to stop activity {MyApp/MyApp.MainActivity}: java.lang.NullPointerException
AndroidRuntime E at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3097)
AndroidRuntime E at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3159)
AndroidRuntime E at android.app.ActivityThread.access$2400(ActivityThread.java:112)
AndroidRuntime E at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
AndroidRuntime E at android.os.Handler.dispatchMessage(Handler.java:99)
AndroidRuntime E at android.os.Looper.loop(Looper.java:123)
AndroidRuntime E at android.app.ActivityThread.main(ActivityThread.java:3948)
AndroidRuntime E at java.lang.reflect.Method.invokeNative(Native Method)
AndroidRuntime E at java.lang.reflect.Method.invoke(Method.java:521)
AndroidRuntime E at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
AndroidRuntime E at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
AndroidRuntime E at dalvik.system.NativeStart.main(Native Method)
AndroidRuntime E Caused by: java.lang.NullPointerException
AndroidRuntime E at android.app.Activity.performStop(Activity.java:3575)
AndroidRuntime E at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3092)
AndroidRuntime E ... 11 more

View 1 Replies View Related

Android :: Activity Restart Crash After OS Kills It

Mar 8, 2010

Activity SplashScreen is the launching activity for my app. It sends a request to my server and gets back a user data it then uses to populate a user object which is a static object. Once it has that it calls the MyMapView activity and finishes itself. A force close occurs when I hit the home button and then open up enough other apps so that Android kills MyMapView to get more resources. Now when I open my app again it tries to start MyMapView and bypasses SplashScreen. There is no user object so I get null pointer exceptions. I have tried to Override the onSaveInstanceState and OnRestoreInstanceState but it seems that those are not available when Android kills the activity. I also tried android:finishOnTaskLaunch with the SplashScreen (maybe this should be put on MyMapView but the article I read said different) and that seems to have no effect. What I would like is for the activity to not restart after Android has killed it. What can I do about this?

View 5 Replies View Related

Android :: Crash When Activity Starts Up And Screen Gets Rotated?

Jun 26, 2009

I am getting a crash intermittently when my Activity starts up either initially or when the screen gets rotated I get several log messages which I have been unable to get any insight from: timeout expired mFreezeDisplay=1 mFreezeCount=0 App freeze timeout expired Force clearing freeze then lots of: Lock_layer timed out (is the CPU pegged?) Key dispatching timed out then I get ANR annotation: keyDispatchingTimedOut the trace has alot of sending signal 3 to alot of PIDs

View 2 Replies View Related

Android :: Design Clarification In Android List Activity Vs Activity

Mar 25, 2010

I have a simple question. I am trying to design a simple Android app, which based on keywords searches something and shows a listing view of results. Currently it merely searches SMSes in the cellphone.Here are some of the things I am faced with: I have a simple first page with a textbox and a submit button. It's rendered by "Activity" inherited class call SMS Finder.once I have the results present with me, I want them to be binded to a list view. Showing preview text to limited characters, say 20 chars. Clicking on the same should "ideally" open the inbox (or outbox or whatever) and open the SMS, however that meant I cannot come back to my app easily. So I would rather open the whole SMS in my own app. So clicking on the app should open the SMS in a new screen with complete message, sender info etc. Few questions here, For generic Android phone apps, what are the best practices to make UI as compliant to as many phones? Like what kind of views should I use?

View 1 Replies View Related

Android :: Intent Activity Crash Behaviour - App Restarts Halfway Through The App

Oct 13, 2010

I have a pretty standard iPhone app that creates a series of around 7 unique Activities initialised by Intents.

However if the app crashes on the 7th Activity, the app restarts on the users phone around the 5th activity. The problem then is the info gathered from activities 1-4 is null, meaning the app is useless and the only way to get the app working again is to either continually press back or else kill the process.

Why does this behaviour occur, and is there a way to force the app to start back at the first activity when it crashes.

View 1 Replies View Related

Android :: How To Handle Activity When Orientation Changes?

Aug 9, 2010

I am writing an activity, that loads data from a server and displays it as a list using ArrayAdapter. For that I'm showing a progress dialog i.e loading, while it loads all data from the server. Then i dismiss the dialog in a handler. My problem is that when ever i change the orientation, the progress dialog is again shown, which is not needed, because all the data is displayed already?

View 1 Replies View Related

Android :: How Does My Activity Knows When The Device Changes In Orientation

Sep 20, 2010

How does my android activity know (is there a callback) when there is a change in screen orientation?

View 1 Replies View Related

Android :: TabActivity Crash When Create Tabbed View In Widget Configure Activity

Dec 4, 2009

I'm trying to create a tabbed view in my widget configure activity. I'm using a tab activity as my activity type and I have the following code..................

View 2 Replies View Related

Android :: On Screen Orientation Changes Activity Restarted

Aug 16, 2010

I know on screen orientation changes activity restarted, but suppose i don't want to restart the activity then what should I do? I had tried it by adding in manifest.xml. android:configChanges="keyboardHidden|orientation"

and override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); }

But still activity restarted each time when I change screen orientation.

View 17 Replies View Related

Android :: Handling Orientation Changes That Occur In Another Activity

Jun 3, 2010

I am having an interesting problem and would appreciate any advice. My app uses WebView as its primary view. Using a javascript hook, it can launch the camera so the user can take a picture. The camera is launched using: Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

When the camera starts, it makes sense to use landscape mode, so the user naturally turns the phone on its side. After the user takes a picture, control returns to my launching Activity (actually, my Acitivity gets restarted because it usually gets destroyed to free up memory for the camera on my Moto Droid). When my WebView gets recreated, I restore its state from the Bundle I saved in onSaveInstanceState().

Now everything looks ok, except the phone is still in landscape mode. However, when the user turns the phone upright bringing back into portrait mode, my WebView takes up only half of the screen. Somewhere along the way, the scale of my WebView got lost. This seems like such a minor issue, but it is driving me crazy.

Does anyone have an idea why this might be happening? What is the correct way to preserve the scale of my WebView? I am hesitant to hard code any scale factors because what looks good on my device may not be the same for another.

View 8 Replies View Related

Android :: Changing Orientation Resets Activity

Jul 7, 2009

I finally got to the point where I was ready to deploy my app to my G1 and test it out and the first thing I noticed was that when I change my phone to landscape view my main activity restarts and resets all of my variables to their default settings. How can I avoid this?

View 7 Replies View Related

Android :: Need To Temporarily Disable Orientation Changes In An Activity

Aug 31, 2010

My main activity has some code that makes some database changes that should not be interrupted. I'm doing the heavy lifting in another thread, and using a progress dialog which I set as non-cancellable. However, I noticed that if I rotate my phone it restarts the activity which is REALLY bad for the process that was running, and I get a Force Close.

What I want to do is programatically disable screen orientation changes until my process completes, at which time orientation changes are enabled.

View 3 Replies View Related

Android :: Setting Activity Orientation By Code?

Nov 24, 2010

It is possible to set the orientation of an activity in the manifest file. but is it also possible to do it from code? if so, how?

View 2 Replies View Related

Android :: Way To Present List To User Where Each Item On List Starts An Activity When Selected

Nov 4, 2010

I am on my first Android application and I am on a timeline so details and examples will be useful since my knowledge is still minimal. I want my first screen to present the user with a list of activities to choose from. In my situation it is a recipe app where the user first chooses the type of food, such as, Beef, Chicken, or Pork. I want the application to launch an activity depending on the list item that the user clicked on. I am not sure if I should use a list view, a text view, a scroll view, a list activity, an activity group...

View 1 Replies View Related

Android :: Can I Temporarily Disable Automatic Orientation Changes In My Activity

May 26, 2010

Can I temporarily disable automatic orientation changes in my Activity? I want to do this when my app does some background internet communication.

View 1 Replies View Related

Android :: ListView In Activity Getting Refreshed On Changing Orientation

Apr 7, 2010

I have Activity with ListView inside it and in the onCreate method of the Activity I have code for populating the Data of the ListView this Data is a server based and so populating includes calling Network URLs. I have the ArrayAdapter of the ListView in the Same Activity Class.

Now the Issue I'am facing is that, in Rest all scenarios my Activity is behaving in a proper way but when the Orientation [ Portrait to Landscaped or other way round] is taking place the Data is Getting lost and Newer Data calls are Required to Populate the Same Old Data now this is something that is not intended out the code how should I deal with it.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved