
Review old projects for Android 4.0. Part two
Most recently, I published a topic that talked about code that worked in Android 2.3, but stopped working in Android 4.0. Several people wrote personally in the mail, thanked for the information and asked to continue such publications. This time, let's talk about the ActionBar. One user had a problem with code that worked on Android 3.0, but again stopped working on Android 4.0.
About 15 years ago, when I began to study programming myself and simultaneously connected to the Internet, I noticed an amazing thing. When I, as a newcomer, asked a question at the Russian-language forum, I received silence in response, or advice to learn the materiel and not to get underfoot. When he asked a similar question in bourgeois forums and even in bad English (he studied German at school), he received detailed answers. Since then, virtually nothing has changed. I have long scored on our forums and prefer to communicate only "there". Surely, many noticed how strikingly different comments on blogs. They have: nice tutorial, thanks for post, excelent article. We have: why the next bike, your horizon is littered, colors of vyrviglaz, vindekapets, etc.
I personally know a few of the “former” who blogged in two languages - English and Russian, and then left only the English part. I see why?
It was the same with my previous post. Here are typical statements: shoot, harsh Chelyabinsk programmers, etc. It somehow coincided that foreign questions came up several times with similar questions, but no one offered to shoot for the wrong code, but simply explained why this should not be done. One example is http://stackoverflow.com/questions/9442527/networkonmainthreadexception-when-reading-from-web . In general, only on this resource, at the request of NetworkOnMainThreadException , 90 results were returned . And no one swears. As they say, feel the difference. The mentality of something like that.
One of the registered users of my site shared this problem . The essence was as follows - The application icon can work as a navigation element and play the role of the Home button, in particular the Habr logo on the site. This is very convenient in some cases when the application consists of several screens and you can "poke" into the system icon of the application for a quick return. An example is described in the documentation and worked perfectly on a tablet running Android 3.0, and under Android 4.0 it suddenly stopped working.
In principle, the answer on the Internet was found quickly, moreover, even in the documentation you can find a solution. But, apparently, the person was simply tired or the eye was blurred, but the person who contacted did not find it. And the chest opened simply. In order for the application icon to work as a navigation element, the setHomeButtonEnabled () method must be explicitly written
It turned out that in Android 3.0 the icon was turned on as the default navigation button, but in Android 4.0 it wasn’t.
By the way, I found an interesting point related to this button. The system allows you to add an additional arrow to the left of the application icon using the bar.setDisplayHomeAsUpEnabled (true) method ;

So, if you call this method, then the previous setHomeButtonEnabled () method does not have to be called, everything works like that.
Good luck with your programming!
A small digression - You are evil, I will leave you
About 15 years ago, when I began to study programming myself and simultaneously connected to the Internet, I noticed an amazing thing. When I, as a newcomer, asked a question at the Russian-language forum, I received silence in response, or advice to learn the materiel and not to get underfoot. When he asked a similar question in bourgeois forums and even in bad English (he studied German at school), he received detailed answers. Since then, virtually nothing has changed. I have long scored on our forums and prefer to communicate only "there". Surely, many noticed how strikingly different comments on blogs. They have: nice tutorial, thanks for post, excelent article. We have: why the next bike, your horizon is littered, colors of vyrviglaz, vindekapets, etc.
I personally know a few of the “former” who blogged in two languages - English and Russian, and then left only the English part. I see why?
It was the same with my previous post. Here are typical statements: shoot, harsh Chelyabinsk programmers, etc. It somehow coincided that foreign questions came up several times with similar questions, but no one offered to shoot for the wrong code, but simply explained why this should not be done. One example is http://stackoverflow.com/questions/9442527/networkonmainthreadexception-when-reading-from-web . In general, only on this resource, at the request of NetworkOnMainThreadException , 90 results were returned . And no one swears. As they say, feel the difference. The mentality of something like that.
New problem - icon does not work in ActionBar
One of the registered users of my site shared this problem . The essence was as follows - The application icon can work as a navigation element and play the role of the Home button, in particular the Habr logo on the site. This is very convenient in some cases when the application consists of several screens and you can "poke" into the system icon of the application for a quick return. An example is described in the documentation and worked perfectly on a tablet running Android 3.0, and under Android 4.0 it suddenly stopped working.
In principle, the answer on the Internet was found quickly, moreover, even in the documentation you can find a solution. But, apparently, the person was simply tired or the eye was blurred, but the person who contacted did not find it. And the chest opened simply. In order for the application icon to work as a navigation element, the setHomeButtonEnabled () method must be explicitly written
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.two);
ActionBar bar = getActionBar();
bar.setHomeButtonEnabled(true);
}
It turned out that in Android 3.0 the icon was turned on as the default navigation button, but in Android 4.0 it wasn’t.
By the way, I found an interesting point related to this button. The system allows you to add an additional arrow to the left of the application icon using the bar.setDisplayHomeAsUpEnabled (true) method ;

So, if you call this method, then the previous setHomeButtonEnabled () method does not have to be called, everything works like that.
Good luck with your programming!