Android :: Handle Orientation Change For A Cupcake Widget?
Jun 19, 2009
Maybe I'm missing something obvious, but how do you handle orientation changes for a Cupcake desktop widget?When it is initially created, the onUpdate method of my AppWidgetProvider calls views.setOnClickPendingIntent(buttonID, pendingIntent) to register for my button events, but when the orientation changes, new buttons are created and I don't have an opportunity to re-register the "onClick" listeners. What is the proper way to do this?
View 6 Replies
May 27, 2009
I have an app that communicates with a server.While it is communicating, it shows a progress dialog.The way this actually works is that I have a class that I call my Network Gateway.Each method takes a Handler as a callback so that the gateway can send back the response as a bundle when it has finished. Right now when someone changes orientation while a network operation is occuring, the activity doesn't know that a thread is running the network code and then the callback might be invalid.What's the right way to do this? I want to make it so that after the orientation switch, the activity can check something to see if a network operation is running and if so, display the progress dialog again and wait for the callback, or set itself as the callback handler now, invalidating the old one.My first guess is that this is exactly the kind of thing services were designed for, but I'd like specifics if anyone can supply them.
View 25 Replies
View Related
Jul 10, 2009
My program does some network activity in a background thread. Before starting, it pops up a progress dialog. The dialog is dismissed on the handler.This all works fine, except when screen orientation changes while the dialog is up (and the background thread is going). At this point the app either crashes, or deadlocks, or gets into a weird stage where the app does not work at all until all the threads have been killed.How can I handle the screen orientation change gracefully?
View 9 Replies
View Related
Jul 22, 2010
I have a widget which has say, a dimension of 294*72(portrait). But when the orientation is changed, I need to change this dimension of the widget to another dimension which would look good on the landscape orientation.
View 4 Replies
View Related
Aug 17, 2010
I have two buttons on a widget that change some items in a widget, if an orientation is changed on a phone, buttons do nothing. I read http://developer.android.com/guide/topics/resources/runtime-changes.html but this is all about activity not widget.
View 1 Replies
View Related
Mar 15, 2010
I am writing a home screen widget and want to update (modify) 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 register to CONFIGURATION_CHANGED action like the code below ...
View 3 Replies
View Related
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
Sep 23, 2009
I know that by default a screen orientation change destroys and recreates an activity, so the activity can load new layout, drawable, and string resources.
I also read about using onRetainNonConfigurationInstance() to save an Object before rotating and getLastNonConfigurationInstance() to restore it after.
But realistically, what are the special cases when an app would use android:configChanges="orientation|keyboard|keyboardHidden" to avoid activity recreation during orientation change? Are there any gotchas involved in using configChanges?http://developer.android.com/reference/android/app/Activity.html#Conf...
View 4 Replies
View Related
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
Aug 11, 2009
I am having a difficult time figuring out a way to read the sensor data from a home screen widget. I can successfully create a home screen widget that extends AppWidgetProvider. I can successfully create a stand-alone application that reads sensor data (extends Activity). What seems to be impossble (for me) is combining them into a home screen widget that reads sensor data. The classes that you have to use, like SensorManager, SensorListener all seem to require an Activity which the AppWidgetProdiver doesnt have. I have also tried keeping my sensor data reader in a separate class that extends Activity and then instantiating that class in my widget. Makes sense in my head but no data is ever read from the sensors.
View 6 Replies
View Related
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
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
Jun 8, 2010
I have an image set as my background and when it is vertical, the image looks fine. However, when the orentation is changed, the image get streched out. If there a way that I can change the image based on the orentation of the device?
View 4 Replies
View Related
Apr 22, 2009
Does Android support Widget run enviroment like WRT (WebRunTime)of Symbian?
View 3 Replies
View Related
May 9, 2010
There is a task to make smt like todo list on widget (with dinamic number of elements), how to organize this list for click support on this elements. I only found how add click event on one widget layout element (with setOnClickPendingIntent), and how send text to widget element TextView. But it's unclear how handle click events for sub-elemets, or how get click coordinates(or item) where was click event. I saw widget "Agenda widget" - and it work fine with clicking on different calendar rows.
View 1 Replies
View Related
Aug 10, 2009
Does anyone know how to handle widget's "Long Click" event on home screen? I want to implement: long click one widget on home screen then one menu will be popup.
View 5 Replies
View Related
Sep 1, 2009
I've built an app widget a fairly simple one that draws an image inside a frame. (If that sounds familiar, that's because it's very similar to the built-in one, but it's a start to something else.)The RemoteView consists of little more than a FrameView and an ImageView. I have a second FrameView that may display or not depending on some certain state awareness.The Image updates on an Alarm schedule rather than the built-in mechanism so the user can adjust this value after installation. The image is set on the RemoteView using a drawable ID from included resources in the package. They've been resized to approximately a quarter of the screen size, but might still be scaled a little by the ImageView.All of this has been working fine. There is one issue that I've been unable to diagnose even the root of the problem.
After an orientation change when the home screen redraws, the ImageView doesn't always draw. The rest of the RemoteView does draw just as it was set during the most recent Update.The mystery is that the ImageView does, in fact, draw if the Alarm is currently set. If it's not currently set, it doesn't draw. Nothing else seems to affect whether it draws or not. It doesn't matter if the widget process is running or not, either (killing it via DDMS and then rotating has the same effect).This occurs in the emulator as well as the G1. During a rotate, the widget gets no update event at all.I could set it to listen for configuration changed broadcasts, but since it works in one of the cases, I suspect something else is going on and that's just an unnecessary piece of duct tape.
View 12 Replies
View Related
Jul 22, 2009
I'm trying to change the icon on the handle when i try to open the slidingdrawer.
When I extract the handle from the view and sets the onclicklistener or ontouchlistener it seems to never get trigget.code...
I was hoping this code should log "onClick" message, but it doesn't. Any ideas?
View 1 Replies
View Related
Oct 14, 2010
I have a samsung tablet.I have a test widget.When I change orientation the widget disappears, but is actually still there (I can long press to remove it).in my res directory,I have resdrawable resdrawable-hdpi resdrawable-ldpi resdrawable-mdpi reslayout reslayout-land reslayout-large-land With valid values in all of these areas, but the widget just will not appear when I go into landscape mode.
View 2 Replies
View Related
Jul 8, 2010
How did you support both landscape and portrait for appwidget? the layout of appwidget will never change when orientate the device from landscape to portrait. by the way, would you please tell me which device support both landscape and portrait for appwidget?
View 1 Replies
View Related
Apr 26, 2010
I have a widget set up and it displays properly in both portrait and landscape when added to each. But when I change orientation it has the problem "Problem Loading Widget". I delete this, re-add the widget, and it displays correctly. Thus, my widget can support both portrait and landscape but it doesn't survive an orientation switch. What am I missing? Do I need to redraw the widget when orientation is changed? Doesn't it do this automatically? Do I need to call onUpdate() somehow?
View 2 Replies
View Related
Jul 8, 2009
I have a widget , thats working just fine in a particular orientation, but the moment i change the orientation to landscape/portrait, the widget is not able to launch. I have one layout and one layout-land folder in res directory.The problem is that the widget created in landscape mode is not opening in portrait mode and vice-versa.
View 4 Replies
View Related
Apr 9, 2010
I want my widget to update when the phones orientation has changed. Before android 2.0 you could register your widget to get the intent on orientation change. Code...
View 1 Replies
View Related
Mar 25, 2009
I am building a AlertDialog in java code, so by default it is portrait but I want to show it in landscape orientation. How to do it in Java code?
View 2 Replies
View Related
Oct 8, 2009
I notice when using the emulator that when the screen is flipped, I get a following logcat message:
INFO/WindowManager(589): onOrientationChanged, rotation changed to 1
How can I catch this in the code? I want to know whenever the orientation changes. I assume I have to set a listener, but I can't find an example anywhere.
View 6 Replies
View Related
Mar 5, 2010
I'm doing an APP that shows some dialogs. Those dialogs are Alert dialogs, and when they are being showed if I change the orientation of the mobile I lost them...they are not being kept on the screen.
View 13 Replies
View Related
Oct 1, 2009
Do Views know changes in orientation? In my case, I create popups from TextView and need to know when the orientation changes(porttrait<-- >landscape). I cannot depend on activity's onOrientationChange.
View 2 Replies
View Related
Feb 11, 2009
I am making an Android app which is currently coming along nicely - I've hit upon a couple of stumbling blocks.
1) How do I stop the screen from going dim/off and the phone locking while the application is running?
2) Can I force the phone to enter landscape mode on running my application?
View 2 Replies
View Related
Jul 1, 2009
My app *sometimes* when orientation change, leaks Activities (getInstanceCount() increases from time to time) and i cannot figure out where references to my Activity or rather Context are kept - tried to use jhat but it couldn't help me much.
what is strange: it doesn't always happen on orientation change, so its even harder to fix.
btw when doing normal app life cycle - start, do something, exit - everything is ok - getInstanceCount() always returns 1.
View 5 Replies
View Related
Apr 28, 2010
I have an activity that checks stuffs online when it's created (is the GPS on and if not it asks if the user wants to turn it on).
The problem I'm having is that it is also doing it everytime I change the orientation of the screen.
I've read some comments on onConfigurationChanged() but is there a better way to be sure I'm checking the GPS only when the activity is first created?
View 4 Replies
View Related