I've worked on iOS app development for five years and I've been trying to avoid working with Android for a while-but things are different now. Whether you believe it or not, Android development is actually a lot of fun, and it's not as big a difference as you might imagine when it's developed in iOS.
I developed this "Seven Minute Workout" app on the Android platform and learned a lot of valuable knowledge. I hope this article will share some of the tips to help you solve practical problems. Please note that what I'm comparing next does not necessarily match exactly, and the focus of this article is not on the full description of Android development; Of course, I will certainly mention all the experience I have accumulated in the process of developing this simple application.
Ide
I choose to use Android Studio, and I'm willing to bet that it will be the industry standard for the future as long as the test is complete. Although many reports say it's running in a precarious state, it only crashes once in my actual use. Maybe I'm just getting used to Xcode.
Java
No matter how you evaluate Java, it is simply a programming language. It solves the problem, and for experienced developers, it's important to focus on the framework rather than on Java. I'm glad I don't have to be involved with the Java EE.
iOS encryption
Mobile application Security Platform-love encryption, in the Android app encryption protection has DEX shell, unique so library encryption protection, resource file Protection and so on. And the introduction of iOS app encryption protection is a global initiative. From local data, method body/method name, URL encoding, program structure, network data transmission and other aspects of the full protection of iOS applications, and can be based on the needs of iOS application users to provide customized solutions for iOS anti-cracking protection. is the iOS app before and after use
Analog device
I always thought the iOS simulator was a headache, but I found myself still too young. After a bit of trying, I decided to abandon the Android emulator and deploy the app directly to the actual device-unless you were willing to take a lot of time to stare at the screen.
Storyboard/nib
I've talked a lot about storyboard on my iOS development blog, and a lot of hard-spoken emails from readers who disagree with me have completely given up on this platform.
The layout format used by Android is XML. They are completely independent of each other. Android Studio also offers a great set of WYSIWYG editors:
But you can still go deep into the original XML-if you want (I generally don't want to be so troublesome anyway).
You can also choose other layout containers, such as relativelayout and framelayout, relative to the automatic layout. Here, we can set the ideal width, height, fill effect, border, and hue with the number of pixels (that is, the device's pixel capacity) or matchparent, wrapcontant, and so on.
Wrap is perfect for text content, it automatically adjusts the correct height and sets the size to fit, and gives the rest of the work to a specific layout scheme such as LinearLayout.
Although I haven't used it yet, fragment seems to be a good way to reuse custom UI elements.
Uiviewcontroller
Android uses an activity to implement Uiviewconroller functionality. Each screen/window is equivalent to an activity. We're here to do most of the work, including binding data to the UI or handling events and so on.
Controller/view Conversion
In iOS we use Segue, Pushviewcontroller, Presentcontroller, and so on to migrate between different screens. But in the Android environment, we need to use intent.
You can easily move to new activity and even pass some of the data to the past.
In the new activity (that is, the myactivity in the above code), we can extract the data that is passed:
You can also use intent to trigger various events, such as implementing table sharing:
Iboutlet
Perhaps people like me, in more than half of the situation will forget to connect Iboutlet.
In Android, each scene/component has a separate ID, as shown in the following:
It will then automatically generate a class called R, and then we can access the buttons in the code as follows:
Label
One of the tricks that iOS developers often use is to use the scene tags to save search information, such as the displacement of the overall layout. In the Android environment, you can also add the entire object to the label, which is very useful.
Uitableviewcontroller/uitableviewdatasource/uitableviewcell
The ListView in Android is the equivalent of UITableView on iOS.
The Uitableviewdatasource in Android is arrayadapter:
Where Listviewitemrow belongs to a row of layouts, equivalent to UITableViewCell in iOS.
The adapter will then create/re-use the rows in the GetView.
You can also set the title like this:
Pictures/Resources
With the help of asset catalogue, picture processing in an iOS environment can be very easy, and developers typically only need to consider both retina and non-retina screens (unless you want to use an ipad-specific image on your iphone).
Due to the different resolution of the devices under the Android faction, you must provide the following four image formats.
They are: mdpi (normal resolution), HDPI (high resolution), XHDPI (Ultra high resolution), and XXHDPI (ultra-high resolution). I personally think that the birth of the xxxhdpi version will only be a matter of time.
When you create a project with Android studio, you only need to provide a copy of the icon, and it will automatically create these four formats. This approach is believed to have left a serious psychological shadow on friends who have worked on Android apps: Don't be afraid, you can then manually replace it with the perfect pixel version.
Therefore, the most basic solution is to create a separate version of each image for each pixel density, set the same name and put it under the correct folder, so that Android will choose the ideal version depending on the specific situation of the device platform.
Custom Fonts
Custom fonts are also very simple to implement on Android: Copy fonts into main/assets and then call them using the following code:
Typeface font = Typeface.createfromasset (Getassets (), "Lato-regular.ttf"); Textview.settypeface (font);
The problem is that this isn't going to work on all the devices, so you need to prepare a fallback font--but neither of my own Android devices provides such a font.
NSLog
The log looks like there's nothing to talk about, and you can use it to debug what the application is (save 1000 words here). System.out.println (..) Also seems to be able to accomplish this task.
Backward compatibility capability
We have all heard of the fragmentation of Android devices. In essence, however, dealing with older versions of Android is no more difficult than using the new iOS feature on older versions of iOS. However, you may need to attach great importance to this compatibility ability, after all, the Android environment, such problems occur much more frequently than iOS.
We can check the current Android version with the following code:
The following code is used to prevent the warning message raised by a function call:
A long and strange journey of Android
Countdowntimer
countdowntimer--I'm really excited about the presence of this built-in feature, because that's what I need for my seven-minute workout app. However, after the actual test, it will not send the last ontick before OnFinish, which is a very strange bug and has not been repaired yet. Weird, it's so weird.
Position
When the user rotates the device in hand, our activity is completely reset, which means that everyone must retain the full state and recovery mechanism after the activity is re-loaded. Processing in an Android environment is a headache, but iOS is good.
Kindle Fire/amazon Store
To get your app into Amazon Store, I just need to make two adjustments to the existing results:
· The YouTube SDK doesn't work because the YouTube app isn't available on the Kindle Fire. However, the ability to support Flash is still preserved.
• You will need to replace the app purchase code for Amazon store.
You can use Android.os.Build.MANUFACTURER and Android.os.Build.MODEL to test the device manufacturer and product model information.
Android Development tips for iOS developers