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.
I'm pretty close to finished with my first game for Android, and I've come across a problem that's so simple I'm sure I'll feel stupid for not knowing how to solve it, but how can I force the app to stay in a Horizontal layout? Right now, if you turn the phone (emulator) it flips the graphics and squeezes them. I want the game to start horizontally and stay that way regardless of how the user turns the phone.
I am new to programming in Java and Android. I got admob to work at the most basic level, and whenever the device is at the landscape orientation, admob tends to popup and occupy a huge potion of the screen.What is the best way to detect the orientation and hide the ads from displaying if it is in horizontal orientation? Is it necessary to put the admob application in a thread to check for change in orientation and hide/unhide it?
I'm new to android and i was wondering if there's anyway to force landscape mode at all times. Another way of saying it, i never want to see portrait orientation on my device. Is there any settings or apps that will force landscape mode at all times (unless an app requires portrait)?
We currently use Activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_x) to set (and 'freeze') the orientation of our app. Froyo now supports two landscape modes tho and we'd like to allow our users to orient the app to 'landscape right' ... ie, the orientation obtained by turning a device naturally oriented to Portrait 90 degrees clock wise.
I want my Activity to be always in portrait mode and I do NOT want the onDestroy() method to be called. There are some interesting articles about that at: http://www.androidguys.com/2008/11/24/rotational-forces-part-four/
The solution seems to be: In AndroidManifest.xml:
I've tried it and it seems to work. Is there any other alternative or is it the correct solution?
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?
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.
It seems like every example I can find of switching between Activity's involves creating an Intent and passing in the context of a View via an OnClickListener associated with a button.But what if you just decide you need to switch Activity's? In my case, a Preference value is causing an Activity switch. How do you create an Intent that can cause an Activity switch without an associated OnClickListener?
I have a little problem with a ScrollView.I have a layout for an activity which is made with a ScrollView. This scrollview contains two ListViews.<?xml version="1.0" encoding="utf-8"?> <ListView android:id="@+id/accountsListView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbars="none" /> <ListView android:id="@+id/cardsListView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scrollbars="none" /> </LinearLayout>In onCreate method of my activity I compute ListViews height according there contents.During execution, on activity launch, ScrollView is already scrolled a bit.So I tried, at the end of onCreate to call method scrollTo(0, 0), but it does not change anything.
I have To set Wall Paper In application by writing the code programmatically. when i press the Grid view Image will get full screen ..... that image i should keep as a wall paper in the android mobile screen how can i do that in programatically. I have done some thing like this ....is it correct or any other way to do it.
Are the following actions possible using the latest version of the Android API?:
Temporarily disable sending text messages Temporarily disable receiving text messages
*Ideally, I would intercept them and queue them up for later delivery. Temporarily disable incoming calls except from certain phone numbers Temporarily disable outgoing calls except to certain phone numbers
Is it possible to remove an application programatically? If so, shall I look at the package manager for that or is there an example some place? When a package is installed, I believe there is a broadcast message to the system saying that. Is it possible to capture that broadcast message?
I have a FrameView that's created in my XML layout, and in my code, I'm trying to create a series of new ImageViews and add them as children of this FrameView. The ImageViews are small, only about 15 pixels square, and I want them to show up in various positions around the FrameView (I'm trying to implement what looks like a radar screen). I'm able to create them and add them just fine, and they show up on the screen.
However, when I try to set their margins, it doesn't seem to have any effect. No matter what I set, all the ImageViews show up in the top left corner of the FrameView, as opposed to offset by the appropriate margins. My XML layout is listed below, along with the code that generates the child views. Am I doing something wrong? How can I get the margins to show up properly? Or is there a better way to do this than by using margins.
I'm writing a simple caesar-encryption-activity. Two EditTexts on screen, one clear-text, one crypted.
Here's an example for the crypted EditText - the cleartext one is similar.
Now when entering cleartext I have an TextChangedListener running that programatically crypts and fills that crypto-EditText. So far, so good.
When the cleartext entered gets really long, the cleartext-EditText scrolls with my imput, but the crypto-EditText stays at the top of the text. I'd really like the crypto-EditText to scroll so that it always shows the bottom line of its content.
How can that be done, preferably from the onTextChanged()-Method of the TextWatcher?
How can we programatically push our app to run in background? I am doing one browser app. and when I am directly launching my application and clicking back key . It will show in the list of background running process.At this time Category is "CATEGORY_LAUNCHER" but at the same time if we try to run same app via third party app.and then clicking back key,its not showing in the list of background running process.Here the Category is "CATEGORY_BROWSABLE".and its not displaying in the list of running process.I noticed that the same behaviour in default android browser. But is their any way to make my app to run in background by clicking back key without killing my application?
I know you need root access if you want to capture a screenshot by using a background application. However is it possible to just grab the screen content of your current visible activity owned by your process? This does not seem like a security constraint since the user has already installed your app is currently using your app. If so how does this work?
I am trying to add permissions to my application manifest, so it can access other apps that the user installs at runtime. I thought the way to do this was to define a permission-tree in the manifest, and then use PackageManager.addPermission() to add permissions under that tree. However, I can't get this to work and the documentation I found wasn't conclusive. Could anybody show me how to do this by means of a simple example?
We are writing an app to substitute screen/pattern lock on G1. Unfortunately, it is impossible to substitute the original screen lock app with a 3rd party one. The only option left is if we can UNLOCK the phone from a service running in the background when G1 is locked. Is it possible? Is there interface to Pattern/Screen lock? What is KeyguardManager for?