Android :: Using ConfigChanges To Handle Orientation
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
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
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
View Related
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
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
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 19, 2010
I understand how to force a specific orientation per activity in the android manifest. I would like to know if it is possible to allow the keyboard to change orientation even though the activity(the layout really) must remain unchanged.
View 1 Replies
View Related
Jul 17, 2009
I have a problem with working with the ORIENTATION values of the SensorManager. I would like to have some kind of 360°-value which directly shows me if the phone is in normal portrait (0°), landscape, portrait turned around (180°) or anything in between. So I could have, for example, an arrow that points to the floor (like gravity would do with a plummet) all the time, no matter how I tilt (sidewards) the phone. I thought this would be easy, but I'm pretty confused at the moment.
First of all, the X value of the orientation-array seems to correspondent with how I turn the phone, BUT: if it's completely uprightly standing, this value is about 60° ... why not 0° (or 90°, 180°, 270°), as I would expect?
Second: The value resets if I turn the phone and Android automatically changes screen orientation. So both in Portrait and in Landscape mode it will be sth. like 60° when the phone is in a 0° angel in real world. I set "android:screenOrientation" to "landscape" but this doesn't help anything :/
I want the app NOT to change orientation when I turn the phone, but I want it to get a continuous orientation value when I tilt the phone.
View 4 Replies
View Related
Jul 29, 2010
I wrote a application that load images from facebook and i show in lmageview, using this below code. InputStream object = myDataFromServer; Bitmap bmpImage= BitmapFactory. decode Stream (object);imageView. setImage Bitmap(bmpImage);it works fine for me. But the trouble is when i run my application for a longer time, it gives me error, OutofMemoryError, and becuse of this error my application crash. so want to know is there any better way to handling images
View 4 Replies
View Related
Mar 24, 2009
Here I have one question about I want to get the handle for one popup dialog, such as, there is one "Delete" alertDialog pop up when you want to delete one picture. So could anyone have the good idea about this?
View 2 Replies
View Related
May 24, 2009
I'm using a mediaPlayer to play sounds in my application. I want the user to be able to adjust the volume by using the hardware buttons on the device. I tried putting this in my oncreate (setVolumeControlStream (AudioManager.STREAM_MUSIC);) but it didn't seem to work. Is there something else I have to do to allow the user to be able to adjust the volume?
View 5 Replies
View Related
Oct 25, 2010
I need to handle home button, redirection of home button on customize way.
View 9 Replies
View Related
Dec 14, 2009
I was wondering whether Androd can catch simultaneous Key Press. For example, a application does something when a user press HOME and MENU key simultaneously. Is it a possible scenario?
View 4 Replies
View Related
Nov 10, 2008
I briefly owned a blackberry not too long ago so that I could handle work e-mail on the go. However, I was disappointed with its e-mail capabilities (or lack thereof) and quickly got rid of it.Due to the nature of my work, I use several different e-mail accounts and I need to be able to access them using imap so that when I move or delete an e-mail locally, it gets updated on the server. Can the G1 accommodate this? For each e-mail account, can you specify things like imap and smtp server?I use a gmail account, a google apps account and three other accounts with other e-mail providers.
View 12 Replies
View Related
Nov 24, 2010
I want to place three button images of same size equal to screen it is working fine in size 320 x 480,it occupies full 320 size but android is having different resolutions of phones of different sizes 480 x 800 and 240 x 320 how I has to place same image for all resolutions equally to occupy full screen ?
View 1 Replies
View Related
Dec 16, 2009
I have a Droid Eris, and I haven't really set it up for email yet. I don't need it too badly, as I use my computer for email, but it might be nice on occassion.I'm wondering if some folks can lend some advice on the best way to have a good working email setup between your phone and your computer, if you don't have IMAP as an option, and don't really use Gmail?I use Earthlink for my main email addresses, and I don't believe they support IMAP, so that's not really an option for me.
View 10 Replies
View Related
Aug 10, 2010
My android application displays webpages(i used webview for it). .but javascript onthe wepage is not running in a webview .If i visit the same webpage through the Browser,javascript is running . How to run javascript in an application(using a webview)?
View 2 Replies
View Related
Dec 23, 2009
I need a way of deleting if my app is been uninstalled. Is this possible? I need to change some data in the database if my app is uninstalled.
View 4 Replies
View Related
Sep 8, 2010
How to handle Home key....Plzz Help me out.We can handle Home button.if you have seen the Nexus One device...when u reset the phone ..and switch it on again some tutorials kind of thng comes..at that time wen u press the home button its not taking u to the Launche Activity...if its not possible then how they are handling over there.I want the Answer..No one in this Blog has any idea how to handle it....or no one has tried on this..sum are sayng that we can handle it by PhoneWindowManager.java class,some r sayng we can handle it by Using onNewINtent() method.But the Question is how we can handle it by these two ways...Just provide me the sample code..where we are handling the HomeKey.
View 9 Replies
View Related
Sep 22, 2010
My app connects to the net and populates a ListView. Sometimes nothing will be returned. What is the best way to notify the user the list is empty?
View 3 Replies
View Related
May 6, 2010
I know Android cannot handle PDFs natively. However, the Nexus One (and possibly other phones) come pre-Installed with QuickOffice Viewer. How would I determine whether the user has a PDF viewer installed?
Currently, the code to start the PDF download looks pretty simple:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
After the download, the user clicks on the downloaded file to invoke the viewer.
However, if there is no PDF viewer, Android reports "Cannot download. The content is not supported on the phone."
I want to determine if the user will get this message, and if so, direct them to PDF apps in the Android Market.
View 3 Replies
View Related
Apr 9, 2010
Is there any "best practice" to deal with plural messages? code...
How could that be done?
View 2 Replies
View Related
Oct 4, 2010
Maybe some of you has an application with quotations or jokes or something. I would like to make a similar. So how can I get the i. element of my string array (which is in arrays.xml)? I don't want to load the whole array in a String[], because it can be too big. Or it's not a good idea to put them into arrays.xml? How do you handle thousands of strings?
View 24 Replies
View Related
Jul 28, 2010
I see that as of API Level 8, you can request a handle to special directories with Environment.getExternalStoragePublicDirectory. This takes a type such as DIRECTORY_MUSIC, DIRECTORY_PICTURES, etc.
I'm looking for an equivalent directory for other media types such as documents (Word docs, PDFs, etc.). My HTC Desire has a "/sdcard/My Documents/" folder which looks like exactly what I want, but it has no DIRECTORY_ specifier for use with the above method. Is this a standard Android directory which I can rely on?
If I can't use getExternalStoragePublicDirectory, I have to use getExternalStorageDirectory instead which just points me to the root of the SD card. I can explicitly check for the presence of "My Documents" under the root and use it if it's there.
This is what I have:
CODE:..........
Is there a better way?
View 1 Replies
View Related
Jan 21, 2010
I want to set an alarm in my application which will be triggered each day. According to the doc, I have to set a one-time alarm, and in the BroadcastReceiver which will receive the alarm signal, reset the alarm for the day after. Is that correct ?
My BroadcastReceiver handles well the wakelock and launch a service which releases this wakelock. Everything works fine here.
However I have problems. In my application there is a checkbox which is checked when alarm is up. To know if my alarm is up, I use the following condition :
CODE:...................
But this doesn't seem to work very well, is that a good way to know if an alarm is up ?
View 1 Replies
View Related
Apr 26, 2010
I'm developing an media player application for Android, for which I need to handle any Alarm notification, and based on that I'll pause my playback. When the Alarm in snoozed or dismissed, I'll then resume the playback.
I googled a lot for the Alarm handling, but what I found was the way to enable Alarm notifications through code, set the intent and then handle it. However, no where could I locate just handling the Alarm notification part. I don't need to set the Alarm on, it could've been set by the user, and I don't need to programmatically. All I need is just handle that notification.
View 2 Replies
View Related
Sep 13, 2010
I have an Activity that will query a RESTful API every x seconds (polls using a handler). The results of the GET are used to update a ListView. This is done using an AsyncTask.
I want to put a Notification in the Notification bar when certain criteria are met in the new data. Everything I have read up to this point has suggested that notifications should be created and updated using a service so that the notifications can be made even when the application isn't in focus. I see the positive aspects of this.
However, I'm unsure if I should just create a service from within my activity or if I need to do something more complex than that. I'm undecided on if I should scrap my AsyncTask model in favor of using the Service to update my list view.
So, my questions are:
1) Is there a good tutorial showing how to make a local service from an activity?
The tutorial doesn't need to show how to make them communicate, the service could be isolated from the main activity.
2) Will #1 provide me with the notification benefits I'm looking for? (Notifications are generated even when the main app isn't visible)
3) Should I use this same service to update my listview?
The service would basically be making the same query that the AsyncTasks are, just doing different things with the results. The app would seem to make more sense to have the Service query, do notification processing, then give the results to the activity, but I haven't found a good resource that clearly demonstrates how to do something like this.
View 1 Replies
View Related
Jun 4, 2009
Im using a mediaPlayer to play sounds in my application. I want the user to be able to adjust the volume by using the hardware buttons on the device. I tried putting this in my oncreate (setVolumeControlStream (AudioManager.STREAM_MUSIC);) but it didnt seem to work. Anytime i press the hardware buttons on the emulator or an actual phone hothing happens. the volume doesnt change and i dont see the volume leve appear on the screen. Every other app i have used works just fine except for mine. Is there something else I have to do to allow the user to be able to adjust the volume using the hardware buttons?
View 5 Replies
View Related
Oct 5, 2010
I am trying to implement smth like context menu but with icons ..
View 1 Replies
View Related