Live data from Hacker News

Android Development Tips For iOS Devs

stuartkhall.com

31–40 of 78 posts

Re: Android Development Tips For iOS Devs

#31

An important correction: Unlike iOS, Android does not come with a simulator. It has an emulator. That explains many of the differences in startup speed and performance. A simulator runs natively and does not have to emulate the ARM machine code on your x86 device. The Android emulator is theoretically more accurate and runs the entire Android OS, but the cost penalty is huge. Therefore, most Android developers test s…

Excellent point. Running the x86 images in the emulator is much faster (and Google recently released x86 images w/ Google APIs in them). Genymotion is a decent alternative to the 1st party emulator, it runs significantly faster.

Genymotion is as close to the speed of the iOS Simulator as you can get today.

However, Genymotion is x86-based, so ARM libraries you use in your app that are designed to run on an ARM device will not work in Genymotion on your computer. However, if your use of those is limited to just a few Activities in your Android app, you should be able to do a lot of things with Genymotion, and just tiptoe around trying out that Activity on your computer and instead use it on-device.

Re: Android Development Tips For iOS Devs

#32
post #21

My experience with ListView was... weird. It doesn't ask you for a height for each row like UITableView does, just for a row count. Then, it measures your views as you return them. This meant that the scrollbar was completely unreliable, it would resize based on the height of the currently visible views. Is there an obvious way around this that I'm missing? ListAdapter doesn't have anything for specifying height.

This is by design in Android. It's very computationally heavy to ask for the heights of each ListView item. Unfortunately I wasn't able to dig up my reference to this. :(

Two more things:

1. The wormy scrollbar is actually standard on Android: the messaging app does it, IIRC even the twitter app on Android does it. So even though your iOS experience tells you it's weird, any users of yours on Android likely won't notice.

2. If your items are all the same height then your scrollbar won't be wormy. So if this is really that important to you, then make your ListView return items that all have the same height.

Re: Android Development Tips For iOS Devs

#33
post #29
post #28

Earlier quoted context omitted.

How is it easier than just pressing the build and run button on XCode?

I think the problem he is having is with how to get to that point. There is a lot of setup to get to the point of just being able to hit the build and run button in Xcode. Of course, once that work is out of the way it's super easy.

What setup work? Install Xcode from the App Store, and log in with your developer account? There is less involved than just downloading and unzipping the Android SDK

Re: Android Development Tips For iOS Devs

#34

Some things I would note: * Do not use getBaseContext() like he does when he created the new Activity. Use getApplicationContext for most things (unless an Activity is required) as this is guaranteed to be the same throughout the lifetime of your application. * For log alternatives, checkout Timber by Jake Wharton ( https://github.com/JakeWharton/timber ) * I would suggest using the Build.VERSION_CODES when making th…

And if you want colored logcat in a terminal window: alias lc="adb logcat | sed -e $'s/^I.*/\e[0;94m&\e[0m/g; s/^D.*/\e[0;92m&\e[0m/g; s/^W.*/\e[0;93m&\e[0m/g; s/^E.*/\e[0;91m&\e[0m/g'"

Jake Wharton also has a neat fork of Jeff Sharkey's colored logout Python script which is pretty awesome:

https://github.com/JakeWharton/pidcat

Re: Android Development Tips For iOS Devs

#35
post #15

"When the user rotates the device your activity is completely reset" You just need to set " android:configChanges="orientation|keyboardHidden" in the manifest. This is very well documented.

This is definitively the wrong way to handle the problem he describes in the article. Even if you set this in the manifest you need to store your state and resume from it correctly. An orientation change is the most common configuration change that causes activities to be restarted, but is far from the only one.

This. The most common other case in which you need to restore state is when your app goes into the background, and is restored.

Re: Android Development Tips For iOS Devs

#36

An important correction: Unlike iOS, Android does not come with a simulator. It has an emulator. That explains many of the differences in startup speed and performance. A simulator runs natively and does not have to emulate the ARM machine code on your x86 device. The Android emulator is theoretically more accurate and runs the entire Android OS, but the cost penalty is huge. Therefore, most Android developers test s…

You can also use http://www.bluestacks.com for debugging/testing your applications.

Re: Android Development Tips For iOS Devs

#37
post #33
post #29

Earlier quoted context omitted.

I think the problem he is having is with how to get to that point. There is a lot of setup to get to the point of just being able to hit the build and run button in Xcode. Of course, once that work is out of the way it's super easy.

What setup work? Install Xcode from the App Store, and log in with your developer account? There is less involved than just downloading and unzipping the Android SDK

(ignoring the creating the developer account) - create certificate(s)

- create provisioning profile(s)

- hit refresh in Xcode and hope it pulls in the profiles you want to use (maybe only an issue if you're a member of multiple teams)

- modify build settings

once you've done that its simple but there is definitely a setup overhead with Xcode and devices

Re: Android Development Tips For iOS Devs

#38
If you want a sort of CoffeeScript experience instead of Java you can also go with Xtend [0]. It's supported best in Eclipse but I do find the cleaner syntax a bit more pleasing to work with. It's only transpiling to Java so you can even mix it with Java while updating an existing codebase or for whatever reason.

[0] https://www.eclipse.org/xtend/

Re: Android Development Tips For iOS Devs

#39

Earlier quoted context omitted.

> Therefore, most Android developers test small changes initially on a device. That's also because deploying an APK on a test device (or several devices) is way easier than deploying an IPA on an iOS device. As someone relatively new to iOS this past month or so, I was shocked by the number of hoops I have to jump through just to take a piece of code I've written and put it on a device that I own and is sitting right…

I would argue that debugging is also infinitely easier in the Android world, since plugging a phone into USB and authorizing ADB gives you full control to see everything on the phone. You can get full logs and debug control over the hardware. You can push and pull stack traces and files to and from the device with a single, three operand command line and obtaining hardware screenshots requires only a click in IDE. An…

You do realize that all of those capabilities are available in XCode?

Re: Android Development Tips For iOS Devs

#40
post #33
post #29

Earlier quoted context omitted.

I think the problem he is having is with how to get to that point. There is a lot of setup to get to the point of just being able to hit the build and run button in Xcode. Of course, once that work is out of the way it's super easy.

What setup work? Install Xcode from the App Store, and log in with your developer account? There is less involved than just downloading and unzipping the Android SDK

I'm not sure if it has changed since I last made an ios app a while back, but there was a fairly large amount of security certificate provisioning and the interface for it, at that time at least, was unintuitive.
Post reply on HN