authors are vetted experts in their fields and write on topics in which they have demonstrated experience. All of our content is peer reviewed and validated by Toptal experts in the same field.
Ivan Dimoski
Verified Expert in Engineering

Ivan is an accomplished Android developer and consultant with six years of experience developing user-friendly applications.

Expertise

PREVIOUSLY AT

Truecaller
Share

Hi! I’m Ivan and I’ve been an Android app developer for quite a while now. Or so it seems. Back in the day (we are talking about 2009), Android was just an infant and I watched the Little Green Man grow ever since. I’m afraid some time ago, Android managed to outgrow me.

Nowadays, Android is not just on tens of thousands of different phones and tablets. It’s on your wrist, in your living room, in your car, 一旦我们开始为无生命的物体分配IP地址, it is going to be pretty much everywhere around us. A lot of ground for even an experienced Android developer to cover!

Also there are over one million apps just on Google Play, 这还不包括亚马逊AppStore或其他我们并不感兴趣的市场, like China. Let’s not forget countless mobile app development companies that generate billions in revenue every year.

So, how can an independent developer 在这个拥有众多玩家的巨大市场中创造一款成功的应用? I have no idea, I haven’t made a successful app! 但是,我做了一个可爱的,我想和你分享我的故事.

Lesson 1: Connect The Dots

成功(通常)不会一蹴而就,这也不是我的第一款应用. I have ones ranging from unexpected over-the-weekend development hits like Macedonian Orthodox Calendar, with over 30,以一种不超过400万人能理解的语言,向1000名用户提供服务, to more successful failures like TweetsPie, an app with heavy media coverage and a terrible user-base of just over 600 active users. A lot of lessons there!

While these apps helped me understand the mind of the “elusive creature called the User” a bit better, the one that inspired me was a two-hour project. Originally developed to make me a millionaire, once 1,428,571名用户购买了这款应用,谷歌从每1美元中抽取30美分, The Dollar App was made to test my merchants account.

Little did I know that years later I will receive an email from a happy mom stating that it was the best dollar that she ever spent since her boy was smiling every time my app gave him a hug.

对于初学者来说,Android应用程序的开发可以简单而有趣.

And that’s how an idea was born! 为什么不利用人类对拥抱的基本需求,让它变得漂亮呢? Make it for a specific audience, interactive, challenging, fun to use, and even more fun to share.

Lesson 2: Understand The Android Market

我上面提到的所有东西加起来就是一个动态壁纸应用. The basics are not that hard to guess. Android的市场份额比iOS大,但iOS用户的消费更多. Messaging apps are wildly popular, but freemium games top the earnings. 中国、印度、巴西和俄罗斯都是新兴市场,但缺乏消费习惯. You can read the App Annie Index for more insights.

So how does a live wallpaper app fit into this? First of all, it eliminates most of the platforms since a live wallpaper is an Android thing. Second, this feature was added in Android 2.所以它有一个很大的社区和很多漂亮的例子. Most notably Paperland and Roman Nurik’s open source Muzei, probably the best reference point for Android development.

While there are lot of live wallpapers out there, most of them fall under the scenic/weather category, and very few fall under the cuteness overload category. This is something we wanted to change and offer something that gives you a smile each time you unlock your phone, 即使你打开它的原因完全不同. 我们给了你一个可爱的小宝贝,让你在晚上睡觉前抱抱你, or when you turn off your alarm in the morning. And even better, make it personal and customizable.

Without further ado, and before we go into technical details, I proudly present you: Ooshies - The Live Wallpaper

Ooshies is the name of my Android app. It may not have been successful but it helped me learn the lessons needed to write this guide for beginner Android developers.

It features:

  • free live wallpaper app that gives you hugs
  • 12 unique ooshies to choose from
  • free, un-lockable, and purchasable content
  • current weather updates
  • social login and data sync
  • seasonal greetings
  • many surprises
  • a ninja cat
  • did we mention hugs?

Successful Android apps sometimes just make you smile.

Lesson 3: Try To Make It Happen

Ooshies似乎是一个非常简单的Android应用程序创意. Paint a background, overlay some clouds and stars, put a bear with a balloon on top, and you are good to go. But no, it’s Android! 看似简单的事情往往是相当困难的,我们倾向于重复相同的 common mistakes over and over again. Here’s a quick rundown of the challenges I faced:

  1. 硬件加速——GPU在这方面做得好得多,为什么还要用CPU呢? Well, it turns out that drawing bitmaps on a canvas cannot be hardware accelerated. At least not for the time being.

  2. OpenGL -如果我们想要硬件加速,我们需要使用OpenGL ES或者更好的 framework that does most of the work for us.

  3. Bitmap loading - a well known memory consumption issue. We need to allocate 1 byte [0-255] of memory, for each channel in the #ARGB, to display a single pixel. 此外,我们使用的图像通常具有比设备显示器更高的分辨率. Loading them all will quickly result in OutOfMemroyException.

  4. 家庭启动器-实时壁纸将在家庭启动器进程中托管, and different launcher tend to give different callbacks to the live wallpaper service (most notably Nova and TouchWiz).

  5. Battery life - if not done right, the live wallpapers and the widgets can drain a lot of battery. With all the buzz about the Lollipop (Android 5.0) terrible battery life the first app to go will be the live wallpaper.

So, overlaying a bitmap, painting it on a canvas, and then switching frames on touch to give a hug, doesn’t seem like a big deal, even when if it is done on the CPU, right? Thats right, it’s not a problem. But, who wants a static live wallpaper? It beats the purpose. The wallpaper should respond to your touches, it should move as you scroll your home screens, 它应该随机做出一些善意的举动,让你感到快乐.

And there is an Android development trick for that. There is a term called the parallax effect for adding depth in a 2-dimensional space. Imagine yourself driving a car. 离你近的房子比远处的山移动得快. 同样的效果可以通过在画布上以不同的速度移动物体来实现. Although, they are all in the same plane, 你的大脑会认为移动更快的物体离你更近. Much like adding drop shadows, the parallax effect adds a z-axis.

And this is where all hell breaks loose! On most devices moving the Ooshie, the weather overlay, and the background, at different speeds, yields significant frame rate drop. Here’s how a single frame is drawn:

    canvas.drawBitmap(background, 0 - offsetX / 4, 0, null);
    canvas.drawBitmap(weatherOverlay, 0 - offsetX / 2, 0, null);
    if (!validDoubleTap) {
      canvas.drawBitmap(ooshinormal, positionX - offsetX, position, null);
    }
    else {
      canvas.drawBitmap(ooshieTapped, positionX - offsetX, position, null);
    }

The offset is a percentage of the distance user has scrolled. It’s a callback that the wallpaper engine provides:

    @Override
    public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep,
                                 int xPixelOffset, int yPixelOffset){
      super.onOffsetsChanged(xOffset, yOffset, xOffsetStep, yOffsetStep, xPixelOffset, yPixelOffset);
      // athe current offset should be a fraction of the screen offset to achieve parallax
      if (!isPreview()) {
        float newXOffset = xOffset * 0.15f;
        wallpaperDrawHelper.setOffsetX(newXOffset);
        if (isVisible() && hasActiveSurface) {
          wallpaperDrawHelper.drawFrame(false);
        }
      }
    }

我必须注意到,如果我知道如何使用OpenGL,那么所有这些都是不必要的! It’s on my TODO list, since anything more complex than what we have now will require a hardware acceleration. But, for the time being I have to work harder, not smarter (I’m open to suggestions in the comments). So here’s what we did:

Lesson 4: Work With What You Have

As a big supporters of the minSdk=15 initiative, from the start we eliminated all the 2.x devices. The effort for maintaining backward compatibility is greater than the possible revenue from users unable\unwilling to upgrade their phones. So, in most cases, we’ll be able to achieve smooth experience with an added option to disable the parallax if desired.

Per this Android development guide, I wanted to give the option to disable the parallax.

Another big optimization is how we handle the bitmaps. A very similar parallax effect can be achieved with drawing two bitmaps instead of three:

  1. Ooshie叠加-修剪和仔细缩放的Ooshie位图(可以附加)

  2. Combined overlay - a combined background and weather bitmap that moves with a fraction of the Ooshie speed

这个Android开发技巧节省了内存并加快了绘图时间, for a slight parallax effect degrade.

When scrolling the home screens, 帧将被频繁绘制(理想情况下每秒超过30次)。. 关键是不要在主屏幕不可见时绘制它们(一些锁定屏幕), some app drawer, opening/switching apps etc.) to minimize the CPU usage.

This is all tied closely with the weather updates. Initially there was a repeating task, executing every hour or two, to sync the weather, but it was really an overkill. 如果用户看不到壁纸,天气信息就无关紧要了. 所以现在,天气更新只有在壁纸可见时才会发生.

    long lastUpdate = prefStore.getLong(SharedPrefStore.Pref.WEATHER_TIMESTAMP);
    if (System.currentTimeMillis() - lastUpdate > Consts.WEATHER_UPDATE_INTERVAL){
        // update the weather if obsolete
        Intent Intent = new Intent(getApplicationContext()), WeatherUpdateService.class);
        startService(intent);
    }

So, basically, here’s the checklist for a memory optimized smooth software bitmap drawing:

  1. Combine bitmaps once
  2. Draw less bitmaps
  3. Redraw only on demand
  4. Avoid background tasks
  5. Offer users some control over the process

Lesson 5: Test. Test. Test

I cannot stress how important this is! Never, I repeat NEVER, release your app before testing it! And, I don’t mean that YOU should do the testing. You wrote the code, you know how it works, and you influence the result by knowing the expectations. 我不是在谈论JUnit测试(尽管推荐),而是关于 staged rollouts i.e. alpha and beta testing.

如果你是Android软件开发人员,那么条款就很简单, but here is a quick rundown:

  1. Alpha testers - a small group of people consisting of your teammates and people from the industry, preferably Android developers. 他们很有可能会拥有高端设备,并且会玩一些 developers options. They’ll send you stack traces, bug reports, and even give you some code/UI optimization tips and tricks. Perfect for early releases with partial/missing features.

  2. Beta测试者——更广泛的受众群体. Stable releases should be published here. Even if your ninja level is too damn high, you can never predict, let alone account, 所有可能的Android发行版和人们使用手机的方式.

Once we passed the alpha, I thought we were done. But, boy I was wrong?! 事实证明,并非所有安卓用户都拥有安装最新软件的Nexus设备! Who’d know? :)

以下是基于这一启示的一些Android开发问题:

  1. Different launchers have different default home screens - usually the first or the middle one, and ,as far as I know, there is no way of knowing it’s position.

  2. It’s hard to center the Ooshie without knowing the default home screen position - thus the settings slider for adjusting the parallax offset.

  3. An average user doesn’t know what parallax offset 手段-更简单的术语应该在设置页面上使用.

  4. A random user will suggest your next feature.

所以我要感谢我们所有的测试者,感谢他们所做的辛勤工作. I hope that getting all the latest features before anyone else is a decent reward for their dedication. If you’d like, you can also be a part of our Google+ Beta Community.

Beta testing is a critical step for Android beginners to keep in mind as they begin programming their successful Android apps.

Lesson 6: Let The Data Speak

Making an Android app that stands out today is a bit more difficult than making a calculator app, when there were none back in 2009. Making the perfect app is hard. Mainly because perfection is in the eye of the beholder. 对我有好处的,不一定对你也有好处. That’s why it’s important to let the app grow. Our roadmap checklist for new features shows that we have enough work for the whole 2015. Among other things we’ll soon include:

  1. Sounds
  2. Seasonal backgrounds
  3. 自定义(背景颜色,天气包,ooshie皮肤等.)
  4. Region specific ooshies (ex. babushkas)
  5. A lot of new ooshies and ways to unlock them

Now, we might have kept the app in beta until all is done, but that way we are throwing away valuable data. 并不是所有的测试者都会花时间给你反馈. 这就是你可以通过使用工具获得反馈的地方. 你可以使用Google Analytics, Flurry, Mixpanel, Crashalytics, ACRA, etc. to collect usage data.

For example, 通过分析数据,我们注意到用户并不经常点击设置按钮, 所以我们让它更明显,并添加了一个快速教程来调整设置.

Although this is a background process, it can be used to further improve the user experience. Why not show the user how many times:

  1. he/she received a hug
  2. how many rainy days were brightened up by a smile
  3. 需要点击多少次才能解锁一个带有迷你游戏的Ooshie
  4. how many friends installed the app because of you

Every Android development guide should tout the importance of Google Analytics in optimizing your app!

这很重要,因为它为他们的行为提供了结果. Don’t make the same mistake our educational system does, making the users passive content consumers. Make them in charge. Give them the option to control their own devices and create their own personal experience. If you manage to package all this into a cute bundle that steals a smile on the first splash, 要求用户为内容解锁提供垃圾信息并不是太牵强.

In the end, you need to evolve your Android app development based on this data as a guide. Although primarily intended for moms/kids, this app may become popular in other demographics. 它可能不符合我们最初的设想,但必须满足用户的需求. Otherwise they’ll find someone who can.

Conclusion

Let’s return to my most successful failure TweetsPie. Despite couple of awards and huge media coverage, the app failed to retain it’s users (the reasons why are beyond the scope of this article).

Success is not always apparent. Thanks to the whole experience I learned a lot. I gave, at least, a dozen lectures on How (not) to fail as a startup 在各种活动和黑客马拉松上,并设法在Toptal获得了几个客户.

Even more important, I try not to repeat the same Android development mistakes with Ooshies by following the tips and tricks in this guide.

To wrap up this long guide, what we define as a success is, at later stage, tightly coupled with what we set as goal in the beginning. 当然,最常见的成功标准是赚很多钱. No matter if your app makes it or not, you must try to make it happen, and believe me at the end you’ll become a better person (hopefully one that manages to learn OpenGL). You’ll make new friends, few enemies, 如果你足够幸运/聪明,你就能让很多用户满意.

You can check our website or download Ooshies to give it a try.

Further Reading on the Toptal Blog:

Hire a Toptal expert on this topic.
Hire Now
Ivan Dimoski

Ivan Dimoski

Verified Expert in Engineering

Stockholm, Sweden

Member since December 11, 2013

About the author

Ivan is an accomplished Android developer and consultant with six years of experience developing user-friendly applications.

authors are vetted experts in their fields and write on topics in which they have demonstrated experience. All of our content is peer reviewed and validated by Toptal experts in the same field.

Expertise

PREVIOUSLY AT

Truecaller

World-class articles, delivered weekly.

By entering your email, you are agreeing to our privacy policy.

World-class articles, delivered weekly.

By entering your email, you are agreeing to our privacy policy.

Toptal Developers

Join the Toptal® community.