We recently released an
Android version for our location-based application creation platform,
Meridian .

Without having to use one of the cross-platform tools like
Titanium , we wrote it from scratch in Java.
')
We decided that it is important to keep the native material native and respect the features of each platform to the maximum. Some such features are easy to follow, for example, adding top bookmarks to the interface window. Others are peculiar only to Android, for example: handling
Intents
,
Intents
old
Activities
, implementing
Search Providers
, as well as strict links to help the garbage collector.
Now our platform uses HTML5 for branding and displaying content, from here we got most of the interface completely free. But a lot of code written in Objective-C needed to be translated into Java, for example: map navigation, direction, and location change.
So, we rolled up our sleeves, installed the Android SDK and got to work.
Development environment

Apple made it easy to develop applications for iOS. Of course, the first step is “Buy a Mac.” Easy! Now download the free version of Installer Xcode from the Mac App Store App Store and start writing code.
Android works a little harder. You can easily
download the SDK , but in reality you will need to first install
Eclipse and download Google's
ADT Plugin .
If you want to lose about a week without even starting to work, then you have a great chance to explore the possibility of writing Java code in Eclipse. You can also download either
Netbeans , or
Scala , or, finally, start exploring
VIM .
But let's assume that deadlines are tight and you want to do it the way Google approves. The first thing you need to do is accept Eclipse as it is.

Most likely, you will hate Eclipse with unprecedented power. It will seem slow, cumbersome and far from what you used to call IDE.
Eclipse is a world in itself. This is an IDE to the last detail, which entails certain consequences. Eclipse has many abstract-sounding concepts that you will have to get used to anyway. There are Workspace, Perspectives and Run Configurations. And by itself, Eclipse is just a shell, in which all the basic functionality is provided through the complex interaction of interdependent plug-ins. This is how it reminds Linux.
Of course, the unusual IDE is not alien to Eclipse; Xcode was also damn unusual at first and it became more and more
meta with each release (schemes, anyone?).
The advantage is that after acclimatizing to Eclipse, you can enjoy some serious wonders: improved performance of auto-code completion, refactoring, and automatic fixes. Simply put, it will write code for you ...

A great way to learn how to use Eclipse is to spend a few hours, and I will be deadly serious, setting up hundreds of options, checkboxes, checkboxes and all the other painstaking things in Preferences.

Again, seriously, I felt more comfortable, familiar and happy with Eclipse, after having dealt with it in the manner described. Does this mean that other programs should provide all the possibilities imaginable? Lord, no. Are you crazy?
Java language
Java is a high level programming language. It is useless to have an opinion on this. Instead, take a better look at how Android
uses Java.
This is how you do something in the background thread. And
this is how you subscribe to events (in reality, this is similar to the
delegate
in ObjC).
This is an explanation of the
Activities
life cycle, which looks like Cocoa's
UIViewControllers
.
In general, the Android framework is very well designed, not inconsistent and works harmoniously with Java. At the core, it is very similar that our applications have almost the same class structure on both Android and iOs.
At the end of the code was amazingly similar to Android. Here is a fragment from our ObjC application that draws arrows.


Brad, right? Many of our source codes are like this.
Debugging
Now that you have written some code, you will want to run it. In the Apple world, we have an iOs simulator.

It is called the Simulator because it pretends (ha!). This is not a real iPhone OS. When you run the application “in the simulator,” Xcode compiles the application to the desktop and runs it in its original format on your Mac. If you look in the Activity Monitor, you will see that the application works along with Mail, iCal and iTunes.
The disadvantage of the Simulator is that it cannot exactly imitate the iOs environment. And your code is not the same, it should be compiled for x86 / 64 instead of ARM, so there is no guarantee that everything will work as well as on the iOs device.
The advantage of the simulator is that it is not an emulator. And what is an emulator?

Notice the Android emulator. His goal is noble: launching your application in a complete and unmodified Android OS, in a virtual machine that performs ARM instructions.
What is the main quality of the Android emulator?

When I first heard about the iPhone Simulator, I thought that it was just awful, until I remembered that we did the exact same program for Windows Mobile a day ago and it was just darn slow.
The Android emulator takes ~ 2 minutes to download on my modern device. But what really upsets is the editing / debugging cycle. Every time I changed the Java code a bit and wanted to return to the application, it took me about 30 seconds to restart the application in the emulator. Compare this with 5 seconds on the iOs simulator. It may not sound much, but think that you will do it hundreds of times during the day.
Fortunately, it turns out that it is much faster to install and download your application to a physical device via USB. So believe me, just go and
buy an Android phone . Better yet, buy a few of them, so as not to have problems with
fragmentation .
Not that fragmentation is unique to Android, it is simply exaggerated in the media. We also need several devices in our iOs lab. One tiny and unexpected difference in an OS or device can cause an application to crash on any platform.
Interface Development Tools
Interface Builder is available for hosting widgets on iOs.

Your experience with Interface Builder may be different from mine, but I learned how to use it very sparingly. It is good when you want to position elements statically with good accuracy. But for dynamic content, especially
UITableViews
, it tends to make everything more complicated than it would be in code. Especially when you return after a while and forget all the small dependencies between the
Controller
and your
XIB
.
On Android, you can create a user interface and design in XML format.

It is a bit like HTML, except that it is not HTML. This is a simple styling system, which is kind of like CSS, except that it is not CSS.
Many well-meaning developers have tried to reinvent HTML and CSS over the years. Mozilla created
XUL for the cross-platform interface in Firefox. Adobe has created
MXML for Flash. Microsoft created
XAML for Windows.
When I had too much free time, I created my own XML system design for Flash called Bent. So I can tell you that the invention of these systems is the funniest thing you can do as a developer. It feels like when you create a Single Platform, as soon as you complete it, everyone will be ready to use it, study and develop with it, will not leave you a single step and will even compose epic poems about what a genius you are!
But the reality is that it is not HTML and CSS, but another thick layer of material that you need to learn and understand, and struggle with the fact that sometimes it does not work the way you want it.
From a positive point of view, you can view XML during development in a visual editor similar to Interface Builder:

It is quite extensive.
Now, technically, you can write everything in Java, just like in iOs you can completely abandon Interface Builder and write only in Objective-C. But you will find out that when you find on the Internet how to do something on Android, you will ultimately have to understand all these XML formats in any case, at least in order to understand the code examples on the website.
But this is not so bad, because you will also appear ...
Real Box Model
Here is a list of items in iOs that displays the search results.

And here is just a fragment of ObjC that renders this item:

Let's talk about sore. Of course, you can create the initial layout in Interface Builder, but then you just have to say goodbye to a
convenient and smooth scrolling . Maybe in the future when iOs devices become damn fast.
As humans, we usually do not think that "The name should be located at 30 - 40 pixels, with a maximum height of 35 pixels." Instead, we think "The name should be above the subtitles, as well as to the right of the image, and have no more than 2 lines."
Android has a markup container system (similar to HTML) that allows you to describe where content should be relative to something. Here is a similar snippet from the same Android search result:

Now you have to learn all these types of markup, such as
FrameLayout
,
LinearLayout
,
RelativeLayout
, and learn all their individual features, but in the end you will get a very natural and flexible UI markup system.
The best part is that no effort is required in order to automatically resize the device for portrait / landscape orientation and various screen sizes. This is a great contrast compared to the absolutely primitive Cocoa / iOS
springs and struts system.
But the nuance about the simplified design of the system in iOs, which I scoffed at, turned out to be a reasonable compromise when I considered ...
Animation
What Android should think about is that it usually looks like this:

It was conceived and developed in the days of Blackberry, Windows Mobile, and the run-up to the iPhone. The influence of these platforms went very deeply into the Android OS.
For example. A display system, that is, a method by which UI widgets, such as menus, buttons, etc. drawn on the screen, mostly implemented by software.
What does it mean? Let's look at the screenshot above as an example. If you press the Down button, you expect the entry “Homepage” to be selected instead of “Go to”. So you press Down. This causes an "invalidate", which means "please redraw the screen." Thus, the screen will be cleared, then:
- The OS updates the status bar at the top;
- WebView redraws Google.com;
- The menu draws a translucent black background and borders;
- All menus and text are drawn;
- A blue gradient highlight is drawn over the “Homepage”.
All this happens very quickly and you see only the final result, so it may seem as if only a few pixels were changed, but in fact the entire screen should be revised and redrawn.
If this sounds familiar to you, it is because this is the main method used in
GDI , the display system introduced in Microsoft Windows 1.0. It sounds suicidal, but in fact most GUIs are managed in this way.
Until the iPhone appeared ...

When you use your iPhone and play hardware accelerated 3D games, you know that everything in 3D is made from hundreds of small triangles.
When you abruptly navigate the list of friends in the Contacts application, you force the triangles to move. And here there is also a “camera”, as in the 3D shooter, but this camera is fixed above the virtual surface of the Contacts application and therefore it seems that the application is 2D.
It was a long way to say that everything on iOs is drawn using OpenGL. That's why the animation on iOs is so fast. You may have noticed that
-drawRect
not called for every frame in the animation. It is called once, then you draw your lines, circles and text on the OpenGL surface (which you don’t even realize), then Core Animation moves these surfaces around, like stringing a string on a puppet. And the final image overlay for each frame is performed by hardware using the GPU.
Apparently, Android made the decision earlier that it was not necessary to force its partner manufacturers to add GPUs. This decision was logical in anticipation of the release of the iPhone, but now it is distressing, as well as a new
hardware acceleration in Android 3.0, which is limited to the initial software build of the system.
Thus, in the beautiful flexible layout system in Android, you need to be very careful. By animating a certain set of properties, you can easily force the processor to make this whimsical and expensive layout on each frame of the animation. And at this time, the processor is very busy parsing some JSON from the web API or something else, okay?
Meridian for Android
In general, it took us about 4 months to develop, create and release
Meridian for Android .

When we first released
Meridian , the number one comment was: “Will you make an Android version, please?”. Even often without the "please".
And it turns out that Android is the third platform for Meridian. The first was Windows Mobile, can you believe it?

We began to create what we now call "Meridian" even before the appearance of the iPhone. At the time, Windows Mobile was the only mobile platform capable of providing us with the desired practical skills.
Thus, it can be said that now I have an extensive idea of ​​all this. There will always be new platforms and new paradigms to explore. The best thing we can do is understand where they came from and take advantage of all the advantages and disadvantages in order to add some amazing features as quickly as possible before they change again.