Screen flip doesn't trigger an orientation change and Activity destruction/recreation

by Rob » Mon, 30 Aug 2010 06:24:49 GMT


Sponsored Links
 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?  Thanks.

--



Screen flip doesn't trigger an orientation change and Activity destruction/recreation

by TreKing » Tue, 31 Aug 2010 05:29:20 GMT


 



Just guessing, but landscape is landscape, regardless if it's 180 degrees,
so the system may not consider it to be a configuration change.



Sounds like a case where you should handle the orientation changes and / or
read the accelerometer values yourself.

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

--


Sponsored Links


Other Threads

1. OOT: Test Please Ignore

Test Please Ignore

-- 
===============
"

2. create spinner with "add item" selection

I have a spinner that is populated by an sqlite db.  However when the app is
first used and the cursor is empty, I want the spinner to offer an option to
add a new item. In fact I would like this option to always be available at
the end of the spinner list, but at this point I will settle for just when
the cursor is empty.  The below code shows what I have tried.  Although the
OnItemSelected method is called when the spinner is created.  Therefore
since the only item is the "Add Item" item, NewItem gets called on creation
instead of when the user selects it.  This would be fine because I could
just ignore the onItemSelected call on creation, but because the item is
selected, when the user then tries to select "Add Item", the
OnItemSelectedListener ignores the selection (which is wrong by the way, it
should be up to the code to do the ignoring not the widget, but that is
another topic).

if (_spinnerAdp.isEmpty())
{
   // GetAddItemAdapter just returns an ArrayAdapter of 1 string
   _spinnerAdp.setAdapter(GetAddItemAdapter(this));
   _spinnerAdp.setSelection(-1);
   _spinnerAdp.setOnItemSelectedListener(new OnItemSelectedListener()
   {
  public void onItemSelected(AdapterView<?> arg0, View arg1, int position,
long id)
  {
 NewItem()
  }
  public void onNothingSelected(AdapterView<?> arg0)
  {
 //when does this happen?
  }
   });
}

Does anyone have a method to do this?  I have seen "add item" selections in
spinners before in other UI Frameworks and think it is intuitive way to get
this done.  I am not stuck on a spinner though if there is another widget
that is easier to get this same thing done...

Thanks

-- 

3. Question about Notification contentView

4. [WTA] Aplikasi yang memberatkan kinerja Procie

5. last block incomplete in decryption

6. How to make a copy of contacts from one account into another account?

7. Java Applet and JAR in Android