i am trying to make a alarm clock, the GlowPadView in the newer android versions it quite good looking and i was planning to use that in my application, but at the same time i also want to support 2.3.3(Gingerbread) which still has a major chunk of phones. So i was wondering if there is a way that i can check the android version the phone is running and show the layout according to that. If the phone is running API 11 + the layout shows GlowPadView otherwise it shows basic swipe views from the Gingerbread stock alarm application.
To check the android version Build.VERSION_CODES can be used
android.os.Build.VERSION.SDK_INT;
So i was wondering if there is a way that i can check the android version the phone is running and show the layout according to that.
Create separate directories, such as res/layout/ and res/layout-v11/. Have the same-named layout resource in each (e.g., foo.xml), and put the GlowPadView in the foo.xml that you place in res/layout-v11/.
As you stated, you could just create two completely separate layouts, and then have an if (android.os.Build.VERSION.SDK_INT > 11), setContentView() to one layout and if (android.os.Build.VERSION.SDK_INT<=11) setContentView() to a different layout.
Related
Well, lately i've been coding an app using 2.3 emulator, I was mainly testing the app in 2.3.7 phone, but yesterday I updated my phone to android 4.0.3 and the UI looks like shit, in fact, keeps the "bad" looking 2.3 UI.
Now i'm trying to get a nice looking app in both versions of android, the problem is that i don't want to have 2 separate projects an edit both of them, so i want to use one single project and 2 virtual machines for the different versions.
The problem is that if i create a project destinated to 2.3 i can't call to HOLO Theme resources, and if I create a 4.0.3 project it will not even work in android 2.3 right?
so... what do i need to do?
thanks.
You need to set the targetSDKVersion as 15, minSDKVersion as 10.
You need to create various resource folders for these two versions. Example, create a folder 'values-v14' inside 'res' folder and define your widget styles for ICS. Have another folder 'values-v10' and keep your styles for 2.3.3
If required, use the version qualifiers to define separate layout for different versions.
The below links will give you more clear idea.
http://developer.android.com/training/basics/supporting-devices/platforms.html
http://developer.android.com/training/backward-compatible-ui/index.html
I have made an app using target sdk version 2.2 ,but for newer version I need to implement the same app on android 4.0 .But when i tested on the device it shows small layouts.
I have some questions:
1.Why is it showing small layouts ?
2.How I can change it?
3.Will there be any other problem related to this when I switch to android 4.0.?
Please answer these questions?
For change layout
In your xml editor .there is combobox for resizing layout check
that.
For Change version
Right click on your current project > properties >android > select
version >ok
no problem for changing
If you are using Eclipse, you can change the Android target version quite easily. Project->Properties and then select Android and change the target version (Note: You may need to use the Android SDK manager to install new targets and AVDs).
You shouldn't have any problem going from 2.2 to 4.0 although again you may need a new AVD or device to test your app with.
Not sure what you mean about small layouts...
Layout:
Your layout is probably set to a specific screen size or density. To support multiple screens, create a layout folder under res. You can create layout folders for specific screen sizes and densities. Something like this:
layout
layout_ldpi
layout_mdpi
layout_hdpi
For more info, check this link
I have an older 2.x Android app that I am finally getting around to testing out on 3.x, and noticed that I can't seem to create a Live Folder for the application on a 3.1 tablet. Is it possible to create live folders for apps on 3.x+ devices, or are they no longer supported?
They are no longer supported. Instead you can create a widget with a ListView inside.
this app brings back livefolders to honeycomb and above
http://play.google.com/store/apps/details?id=arnodenhond.livefoldershortcut
http://code.google.com/p/livefolder-shortcut/
i used this source code for my project. i think it will also used full for you. http://androidostutor.net/android-live-folder-example/
I have a app which has 2 widgets, lets call them SimpleWidget and ListWidget.
ListWidget makes use of android 3.1 (api level 12) features.
What I would like to do is register both widgets if the device is 3.1 or above.
If it is not than I would only want to register SimpleWidget.
As the code stands now the widgets are defined in my app's AndroidManifest.xml file.
I can't figure out how I could filter this by sdk level.
The only solution I have found so far would still display both widgets (in android's add widget page) even on pre 3.1 devices (in which case I relegate ListWidget to a SimpleWidget).
Am I missing something?
For example can I register widgets in Java code (maybe in the app's onCreate method) instead of in the manifest file? (seems unlikely since the info is needed before the app is ever run).
I've written a relatively simple app, and I've been testing it out on the various different API levels created through the SDK and AVD manager in Eclipse. It works great in all API levels except for level 3. I have a few spinners on the front page which work just fine, but my four buttons don't seem to be working. I've tried adding a breakpoint in one of the 'onClick' methods that I specified in my xml layout file, but the breakpoint never seems to get reached. I'm kind of at a loss here. Does anyone have any idea what could be going on here?
Level 3 does not support the onClick attribute in XML. Unfortunately, you'll have to wire up OnClickListeners in code.
... or drop support for 1.5. It's a small and shrinking part of the market.