RemoteViews.setInt() not working on Android 2.1 - android

I'm using the setInt() method of RemoteViews to change the alpha of my appwidget's background. The documentation tells that the method is available since API level 3, unfortunately it fails on an Android 1.6 emulator and also on a Samsung Galaxy S device with Android 2.1-update 1. So, what Android versions currently support this method and should I use it at all, as it seems too risky to implement?

Related

What are API levels in Android?

I am starting to learn android development. I downloaded adt-bundle-windows-x86 from the android site. Now when I open the SDK manager that comes with the bundle it enlists a number of API levels. My phone has ICS. But when I saw wiki for the same it seems we can have more than one API levels for a single code name.
Which one is to be used? I want backward compatibility and also not miss on the new features that might have been introduced in ICS. what do these API levels mean and how do I decide which one to use?
Here is a link to the list of Platform Version - API Level - VERSION_CODE - Notes
This link shows data about the relative number of devices running a given version of the Android platform.
I recommend:
minimum sdk version = Android 2.3.3 - Gingerbread - Api level 10
target sdk version = Android 4.3 - JellyBean - Api level 18
NOTE the target sdk version most of the time should be the latest release which at current is JellyBean
Here you can find a list of api levels, code names and usage statistics.-
http://developer.android.com/about/dashboards/index.html
You should try making your application compatible with as much devices as possible, so I'd recommend to make sure that works fine at least on Android 2.3.3 - Gingearbread - Api level 10
Regarding new features, sadly, keeping in mind old devices sometimes means forgetting about some new cool features or apis which are included to make our lives much easier.
I think this can help you a lotclick
You should set api level as minimum as possible like 2.3.3 gingerbread. 35% of android devices still runs on Gingerbread. But as per your question it seems like you wanted to start development from 4.0.4 ICS. So set your min SDK 14. And as far as new graphical or library changes google provides support library for use.
One suggestion set max api level as high as possible. I mean 4.3 for now. hope this would help

Accessing the new Notification Settings in Android 4.3 through Code

How can I access this through code? So I can open it for the users automatically and they don't have to hunt through the Security settings to enable it.
I am unable to find it in Android Studio using startActivity(new Intent(Settings.<>));, where <> is the list of setting screens.
Image courtesy of Android Police
There is an outstanding bug in Android 4.3 where the notification listener screen action is not listed in Settings. The current workaround is:
startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
The bug that #CommonsWare mentioned has been fixed as of Android 5.1 (API 22). You can now use this to bring the user to the Notification access screen:
startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));
I've tested this across multiple Genymotion instances (4.3, 4.4, and 5.1) as well as a Galaxy S3 running 4.3, and this solution has worked perfectly in each case.
Strangely however Android Studio does give me a warning when I use this field on pre-API 22 projects, despite the fact that it works without problems:
Field requires API 22 (current min is 18): android.provider.Settings#ACTION_NOTIFICATION_LISTENER_SETTINGS
I believe that this warning should be able to be safely ignored, similarly to how you can use values from Build.VERSION_CODES on any version of the platform.
Link to the documentation: Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS

How to check if a phone has hardware menu button in Android 2.1?

I'm trying to figure out if an Android phone has hardware menu button, I've searched and found this method:
ViewConfiguration.get(getApplicationContext()).hasPermanentMenuKey();
But this doesn't seem to work in Android 2.1, and I'm trying to create an app that works on Android 2.1 and higher. Is it possible to detect if there is an hardware button on a phone with Android version less than 3.0?
Every compatible 2.1 android device had a menu key as it was part of the CDD:
http://source.android.com/compatibility/2.1/android-2.1-cdd.pdf
See section 8.7:
"The Home, Menu and Back functions are essential to the Android navigation paradigm. Device implementations MUST make these functions available to the user at all times, regardless of application state."
Therefore, if the device is running android 2.1 it's safe to assume it has a menu key. If it's running a later version you can use the API you found.
hasPermanentMenuKey() was introduced since API Level 14 because from Android 3.0 the devices were allowed not to have a menu key. so I assume that you can safely assume that a 2.1 device will have a menu key. Check the android documentatin on this for more. Android view Configuration hasPermanantMenuKey
hasPermanentMenuKey() became available at API level 14 (3.0). I would believe it is safe to assume there is a key on devices running below 3.0. Above 3.0 you can call this method to determine if you need to provide an alternative method.

android what to worry about when deprecated API still working in higher API version

Made an app targeting API8 and it's running fine
on all emulator images all the way up to API15.
I cannot test the app on other higher apis so I'm not
setting the android:targetSdkVersion.
What about this deprecated warnings:
android.view.Display.getHeight()
This method is deprecated.
Use getSize(Point) instead.
Can I ignore this and just keep on using Display.getHeight()?
I read about reflection or programmatically testing what Android version the device is using.
Why do people do that when it's working for me?
I cannot test the app on other higher apis so im not
setting the android:targetSdkVersion.
If you are testing "on all emulator images all the way up to API15", then you are "test[ing] the app on other higher apis".
Can i ignore this and just keep on using Display.getHeight()?
In Android, "deprecated" usually means "we have a better solution that you should consider using, but we will keep the deprecated one working as long as we can". Sometime after you drop support for API Level 12 and down, you might wish to move to getSize(). For now, getHeight() should work fine on all Android API levels.
Why do people do that when it's working for me?
They do not do that for deprecated APIs. They use version checks and the like for accessing things that simply do not exist in older versions of Android, so they do not try referring to non-existent APIs on older devices.

Android dalvik problem

Please i have different platforms installed. I just wanted to know what am supposed to do. If i develop with 3.0 platform, would those with a 2.2 be able to use my app??..
The second question which is the main question is I always get this error when i create android projects..
[2011-05-16 16:32:21 - Hello World] Dx no classfiles specified
[2011-05-16 16:32:21 - Hello World] Conversion to Dalvik format failed with error 1
What do I do to it?
There are several reports out there for that error (e.g., this one. All the solutions point simply to reload the project (select it in the tree at your left, and press F5).
Regarding the first question, unless you want to support Honeycomb-only features, then set up the api level to 8 (Froyo).
Eclair, Froyo and Gingerbread are android versions 2.1, 2.2 and 2.3 respectively (also referred in the documentation as API levels 7, 8 and 9). See the table here. If you want to support just mobile phones, set your target to 2.1 or even lower. That way you will be able to target most of the phones in the market. Your app will also run in Honeycomb (3.x) devices.
Honeycomb has new features to support larger screen devices, so if that is your main target, you might consider taking advantage of those features and drop cell phone support. All will depend on what is your objective.
you should have a look at the minSdk and targetSdk features of a manifest file :
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8" />
This will help you target a android sdk version and precise what is the minimum sdk level that can run your app.
Regards,
Steff
Developing for Honeycomb or non-tablet version of Android, is different in various things. Your 2.2 application should run correctly on a tablet, but if you want to optimize the graphical interface and use all the notification and other things included only in Honeycomb, then you must use the appropriate API. Until Ice Cream Sandwich is released, we have to develope two different application for the best result.
Regarding the error you get with android projects (I suppose under eclipse?) you'll find some detail at this link, but if you follow all the instruction provided by google in the developers page, you'll be able to write and run your Hello World application.

Categories

Resources