Smart TV is becoming more and more popular. Huawei said it would release smart TV in April, and OnePlus also said it would layout smart TV in the future. In the direction of smart TV, Xiaomi has been a pioneer. But there are many developers who think of smart TVS as simply enlarging the screen of a phone, which is not the same thing.

A, sequence

You will gradually find that all the TVS around you have become smart TVS. It’s easy to accept the fact that smart TVS are cheaper.

Price is a sensitive point that can not be ignored, and customers will naturally choose smart TVS with good quality and low price. It may seem illogical, but why would a traditional TV, which doesn’t allow Internet access, be more expensive if it’s a laggard technology?

Manufacturers’ profits from hardware are fixed. When Xiaomi launched “the first TV for young people”, it held user data in its own hands and realized monetization by building and operating advertising, paid content distribution and other service means. Revenues from services subsidise the cost of hardware, driving down the price of smart TVS.

This is easy to understand, before it was pure manufacturers, sell a TV to earn a TV, apart from the need to provide warranty service, this is a hammer sale. And when the TV is connected to the Internet, you can expand the possibilities. Every step you take, you have the experience of advertising, the TV App recommended to you, the paid video you watch on the TV. These are all fees for the service, and the manufacturer can get value from you throughout the life of your TV.

TV manufacturers are already turning from manufacturers into service providers. Smart TVS are a general trend. There is no turning back. There may be some manufacturers that continue to produce niche traditional TVS, but only niche ones.

As for the smart TV system, thanks to the opening of Android, the market share is the largest Android system, other Apple TV, Chromecast are relatively small. Since last year, Samsung has chosen Android as the operating system for its new TVS.

When it comes to smart TVS, Android is the mainstream.

Many people think of Android TV as mobile, but it’s not the same.

Ii. Technology and Android TV

There’s no doubt that as long as you’re an Android developer, it’s easy to get started on an Android TV project.

But it’s not quite the same, it’s not as simple as thinking of TV development as a bigger phone, there are a few details that need to be polished.

In this article, I’ll take a fresh look at some of the technical aspects of Android TV development.

2.1 Different design styles

The most intuitive feeling of TV is the big screen, but it can not just be regarded as an enlarged version of the mobile phone, there is a fundamental difference.

When doing TV UI design, we should consider the design in two or three meters away, but also can see, TV and mobile phone line of sight is not the same.

When doing a design, pay attention to effect of chunk, blank, roll, focus etc., understand the difference among them can.

2.2 API differences

It’s all Android, and the same set of apis that you can use on your phone, you can use on your smart TV. Smart TV uses an API that is complementary to mobile development.

For the simplest case, mobile phone operation, click a content only two states, normal state and press the state, and there are three states on TV, no focus state, get focus mode and press state, which requires the mobile android: do not use in the development of focusableInTouchMode attribute to support.

There are also some focus processing, such as focus animation, focus recording, focus addressing, etc. Although Android uses the nearest principle to calculate the direction of the next control to get the focus, but sometimes we still need to code to control its addressing effect.

There are a lot of API differences in TV development, here is not one example, in fact, many effects can refer to Leanback implementation, this will be introduced later.

2.3 Related Tools

In TV development, there are also tools that can make our development more efficient.

While smart TVS are essentially Android devices, most TVS and smart boxes come out of the factory with ADB debugging turned off. If you work with vendors or search forums, some devices have special Settings that allow ADB debugging to be turned on. Once debugging is enabled, we can connect via ADB Connect, and debugging is no different from normal mobile development. Reference: Common ADB commands

TV debugging can sometimes be a hassle, but if you don’t have a strong need for specific hardware, you can just use a normal phone for development and debugging.

TV and mobile phones interact differently. Mobile phones touch the screen, while TV can only be controlled by the buttons of a remote control. So to simulate the TV remote on your phone, here’s a Chrome plugin: ChromeADB,

Only need to ensure the development device and debugging device, ADB smooth connection, through ChromeADB, to achieve some simple up, down, left and right operation of the remote control.

2.4 Google’s Leanback Program

Leanback is an open source UI framework for Google Real TV. You can use Leanback to quickly achieve UI effects. Leanback is mainly based on fragments.

In domestic TV App projects, the effect recommended by Leanback is basically not used, just like Google’s Material Design Design. All the designs are forwarding articles, but they are not used. However, this does not prevent us from studying its implementation.

Leanback RecyclerView provides some headache focus memory, focus item enlargement, focus block center when rolling problems are packaged, simple enough to use.

The biggest problem of Leanback is that it is a V17 project, that is, minSdkVersion is 17, while in the domestic environment, TCL and Lenovo are still producing TVS and boxes below 4.2. That said, for a commercial project where you want to rely entirely on Leanback’s official guidance to develop your App, there will be a portion of the device market that will be abandoned.

But this is not a bug that can’t be fixed. My impression is that some data refresh notifyDataXxx() method has API Level requirements. Therefore, you only need to realize this part of logic by yourself, and you can use Leanback on V14 devices.

I’m going to skip the code and just search “V14 Leanback” on Github.

Leanback – GoogleSample Github:github.com/googlesampl…

2.5 audio and video

Smart TVS can be loaded with apps, but ultimately, it’s all about watching TV. Most TV apps focus on audio and video content distribution.

All the mainstream video apps you can think of have TV version apps, so the direction of audio and video will inevitably be encountered in TV development.

Regarding audio and video directions, it is easier to find an open source library on Github to package it, but it is also difficult to troubleshoot problems without knowing the details. If you want to study in this direction, I recommend a book called Android Audio and Video Development by He Junlin, a former audio and video expert of IQiyi.

If I had just one piece of advice for smart TV audio and video, it would be to be careful with hard, hard, hard.

This is easy to understand, now a smart TV is cheaper than many mobile phones, the biggest cost ratio in the screen, you can imagine its other hardware, is not as good as Xiaomi hundreds of mobile phones.

When you use hard solution, the performance on some low-end devices is out of control, and you will encounter very disgusting black screen, Mosaic, splintered screen, etc. So if you don’t have that much experience, go straight to soft solutions.

2.6 Screen Projection protocol

The real need of TV, or the need to watch TV, any need for strong manipulation, on TV is a fake need.

With smart TVS connected to the Internet, we won’t have to watch TV live. To stream content from your phone to your TV, this involves a screen-casting agreement.

There are many screen casting protocols in the market. Anyone who has some idea of screen casting will customize a screen casting protocol. The only mainstream models are Google’s DLNA and Apple’s AirPlay, which are now standard on smart TVS.

Just like the relationship between wechat and mobile phones, if a mobile phone wechat exit to the background will not receive messages, users will only say that there is a problem with this mobile phone but not wechat. The same applies to smart TVS.

But there are some, whether it works or not is another story. All screen projection protocols exist at both ends, the client end and the receiver end. When smart TV leaves the factory, it integrates the protocol of the receiver end. If it is not easy to use, you can try to install “Letbo Screen projection App” to solve the problem.

Most of the time, we are dealing with the client side of the protocol. Here we recommend an open source project, ConnectSDK, which supports most of the protocols.

ConnectSDK is a full platform SDK. Access is well documented and examples are not covered in detail here.

Liverpoolfc.tv: connectsdk.com/

Github:github.com/connectsdk

The screen casting function is integrated in most mainstream video apps. There are also niche apps, such as Quick Screen, that can stream content from some video sites to a smart TV.

Projection screen in the smart TV technology stack, must be lit.

2.7 Local Services

Or to solve the problem of difficult operation on TV, for example, the simplest demand, want to download a good Blu-ray HD movie, Copy to watch on TV, the operation is not small.

So many apps build local services that allow users to transfer files between TVS and other devices.

There are many open source projects to choose from to start an HTTP service on Android.

Nanohttpd is recommended as a single file to implement a native HTTP server on Android. And use a lot of people, upload files, webserver and so on has been implemented, out of the box.

Github:github.com/NanoHttpd/n…

Summary moment

I think by the end of this article, you should have a basic understanding of Android smart TV development, and no longer think of it as a phone with a larger screen.

As mentioned above, smart TV is bound to be popular. I recently saw that companies making short videos like Toutiao have already opened product positions for Android TV. I think there will be more and more positions related to TV development in the future.

What else do you know about smart TV technology, feel free to discuss in the comments section.


Public number background reply growth “growth”, will get the learning materials I prepared, can also reply “add group”, learning progress together; You can also reply to “questions” and ask me questions.