Android Tutorial Make your app compatible with Android 5.0 devices

This is an old thread. It is not relevant if you are using newer versions of B4A.

In order for your current applications to run properly on Android 5.0 devices you need to:

1. Compile your app with B4A v3.82+
2. Add this line to the manifest editor (assuming that you didn't set a different theme).
B4X:
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
Without this line the new material theme will be used. The material theme (at least currently) has some issues that can break existing layouts.
3. If you are using the StdActionBar and handling the ButtonClicked event then you need to update the library to v1.52 (otherwise the app will crash). Note that the ButtonClicked event will not be raised on Android 5 devices.
You should handle the Activity_ActionBarHomeClick event instead of StdActionBar_ButtonClicked event. The Activity_ActionBarHomeClick event will work on all versions.
 
Last edited:

hmotiwala

Member
Licensed User
Longtime User
For that I will have to wait till I get android 5.0 update on one of my devices. This behavior is reported to me by some users who have nexus 5 with Lollipop. The application runs just fine on my device with kitkat on it. I was just posting here to see if anyone else has seen similar behavior and may be there was a known fix for it.
I will put this issue on hold for now, till I am able to test on android 5.0 myself.
 

Douglas Farias

Expert
Licensed User
Longtime User
holo.light go work too erel? i dont have the 5.0 to test =(
 

drgottjr

Expert
Licensed User
Longtime User
If you set this theme directly you have to change the minSdkVersion to 11 since Theme.Holo is introduced in API Level 11 and is not available in previous Android versions.

If you want to still support older android versions use the method in this tutorial: http://www.b4x.com/android/forum/threads/theme-based-on-version-tutorial.27624/#content


i added SetApplicationAttribute(android:theme, "@android:style/Theme.Holo") to the manifest and set minSdkVersion = 11,
and there is still no bitmap in msgbox2 on my android 5.0.1 device. is there anything else that should be set? thanks.
-go
 

corwin42

Expert
Licensed User
Longtime User

corwin42

Expert
Licensed User
Longtime User
re lollipop issues: i noticed that the little icon/image that use to appear next to the app's title is no longer there.
i've added SetApplicationAttribute(android:theme, "@android:style/Theme.Holo") to the manifest
i've set minskd = 11
i'm compiling with b4a 4.0
(above behavior is in addition to msgbox2 still not showing bitmap)

anything else needed? thanks.
-go

If you set a holo theme the application icon should show.
 

drgottjr

Expert
Licensed User
Longtime User
If you set a holo theme the application icon should show.

you're right. i did set the holo theme and the minsdk, but there were a couple things you mentioned in a different post which, when done, seemed to do the trick. i have the icon application back, but, as erel has mentioned elsewhere, the icon in msgbox2 will not appear. my real concern, of course, is that something major will fail under lollipop. setting the holo theme, the minsdk and the target seems to cover the bases. i've even included the themes.xml you mentioned (in a slightly different context). it doesn't appear to hurt. my apps all appear to function under lollipop, but i didn't start looking closely at ui until i noticed the slight differences between my 4.x device and the recently upgraded 5.0 device. thanks for a major help.
-go
 

corwin42

Expert
Licensed User
Longtime User

pesquera

Active Member
Licensed User
Longtime User
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
Hi Erel, doing this was perfect for me but.. on an old device (Android 2.3.6) the labels don't show multiline.. just they show the first line
I solved this changing the view from Label to EditText with the propertia SingleLine=False and Enabled=false
The problem is that I must change many labels on this way.. is there some trick to solve this better? (I like this theme)
thanks!
 

tagwato

Member
Licensed User
Longtime User
Hello,

Setting Theme.Holo as explained here does improve apps compatibibility with android 5.

But this workaround has some drawbacks, at least for me: a) the above theme adds an animation when loading layouts; b) also, a kind of gradient color is shown in the background of the activity and panels.

Question: is there a way to inhibit these two behaviours of Theme.Holo? Or, is there any other Android 5 compatible theme which doesn't show these behaviours? I'd like especially to get rid of that animation feature.
 

tagwato

Member
Licensed User
Longtime User
You can disable the animation by setting Animation Duration property to 0 (in the designer).

You can change the activity background color to remove the gradient.

Thanks, Erel. It works.
 
Top