Any mobile software development needs to be done with an awareness of the end user experience. This is true in any other domain as well. But special mention here on mobile development as end users are used to responsive apps on the mobile and any small delay is perceived as un-responsiveness or worse that the application has hung.
One of the basic principles to provide a very responsive application is to handle any time consuming code in a separate thread not the main thread or the UI thread as it is also known. So, it is very essential to understand about how to spawn new threads (worker or background threads) and how to come back to the parent thread.
How do the 2 threads (parent/UI and the worker threads) communicate? Here comes the Handler. By definition A Handler allows you to send and process Message and Runnable objects associated with a threads MessageQueue. Each Handler instance is associated with a single thread and that threads message queue.
So, let us take the handler from the main thread and see how we can use it to communicate with a child thread.
When a handler is created, it is associated by default with the current thread. So, we have this piece of code in the main activity class:
Now, I spawn a new thread through a method that is called when I click a button. So, let us see the button piece of code first:
private Handler messageHandler = new Handler() { };
public void handleMessage(Message msg) { super.handleMessage(msg); progressDialog.dismiss(); }
@Override public void onClick(View arg0) { fetchData(); }
Now, on click of the button, the fetchData() method is invoked. Assuming that this is a very time consuming task, I will spawn a thread and do the task and return from that thread as shown in the code below:
Since it is time consuming, I am starting a ProgressDialog just to inform the end user that some activity is happening. Then, I start the thread, make it sleep for 800 milliseconds and send back an empty message through the message handler. The messageHandler.sendEmptyMessage(0) is the callback on the parent threads messageHandler to inform that the child thread has finished its work. In this example I am sending an empty message. But this can be the means of communication and exchange of data from the child thread to the parent Thread.
Now the control returns to handleMessage() call back method. That method shown in the beginning just dismisses the progressDialog.
In real life cases, within this thread we can do things like calling web-services, calling web-sites to fetch specific data or doing network IO operations and returning actual data that needs to be displayed on the front-end.
I will take up an example of an HTTP call invoked through such a thread in the next tutorial.
Also note that the Android UI toolkit is not thread-safe and must always be manipulated on the UI thread only. So the child thread should return all data and the painting of the UI should be left to the main thread or any UI specific thread.
There is a better way of handling this through the use of AsyncTask, a utility class available from SDK 1.5 onwards. It was available as UserTask earlier.
Here is the complete downloadable code for this tutorial.
Tor and Chet talk with Tim Kilbourn from the Android TV team. Learn about developing apps for this new platform and hear about exciting things in the TV world like "overscan" and "D-pads".
Subscribe to the podcast feed or download the audio file directly.
Relevant Links:
TV Leanback API: https://developer.android.com/reference/android/support/v17/leanback/package-summary.html Android Style Guide: http://developer.android.com/design/style/index.html Nexus Player: https://play.google.com/store/devices/details?id=nexus_player Gamepad for Nexus Player: https://play.google.com/store/devices/details?id=nexus_player_gamepad
Cara Menonton Streaming TV di Android dengan Mudah Lingkaran Anda akan memberikan Tips untuk kamu tentang Cara Menonton Streaming TV di Android dengan Mudah.
Memang fitur menonton TV lewat handphone menjadi keunggulan tersendiri di Indonesia maupun China, tapi sebenarnya Android yang selalu mengusung handphone dengan banyak fungsi tidak mau kalah, karena Anda juga dapat menonton channel TV swasta seperti RCTI ataupun SCTV pada smartphone Android Anda.
Caranya memang tidak semudah handphone yang memang telah dilengkap TV tuner, pada artikel ini akan saya bahas secara lengkap. Cara untuk nonton streaming lewat Android membutuhkan Aplikasi pihak ketiga untuk membuat handphone menjadi support terhadap video saat streaming, cara kerjanya mirip dengan flash player di PC. Aplikasi yang saya pilih adalah MoboPlayer, Anda dapat mendownload di play store, lalu install Aplikasi tersebut sesuai dengan Android Anda karena saat install akan diberikan pilihan codec, codec ini berbeda di tiap Android.
Setelah Aplikasi Mobo Player terinstall, tinggal buka Aplikasi tersebut dan masukan link streaming channel TV yang ingin Anda tonton pada menu yang telah tersedia, link streaming telah saya berikan lengkap di bawah.
Pertanyaan di setiap streaming tentu sama yaitu mengenai kualitas gambar dan lag, nah untuk ini semua tergantung pada internet Android Anda. Iya, berbeda dari TV Tuner yang telah ada, tanpa memerlukan internet, pada streaming semua tergantung kekuatan sinyal internet Anda, bila sinyal stabil dalam kondisi 3G biasanya gambar streaming pun akan bagus dan tidak ngadet.
Sekian Cara Menonton Streaming TV di Android dengan Mudah yang dapat saya berikan kepada kalian. Bagi yang ingin bertanya atau menambahkan bisa melakukannya pada kolom komentar, semoga artikel saya dapat memberikan informasi. Terima kasih telah berkunjung.
In depth The scary interactive future of TV has arrived
Gracenote is planning to take control of your TV.
The company, ubiquitous with music metadata services, has developed a suite of technologies that take the concept of interactive TV to an unprecedented level.
From next generation programme guides to personalised ad replacement, via fluff like The Million Second Quiz, the company is reinventing the very foundation of television.
"This is disruptive tech," company president Stephen White tells TechRadar with casual understatement. At first glance, what Gracenote appears to be doing seems innocuously clever. The company has developed a next generation programme guide, due to make its debut on LG screens this autumn.
Called On Now, it presents a highly graphical interface of whats available to watch. Instead of scrolling through a traditional timeline, the On Now guide presents content by programme, genre, cast or crew. The viewer navigates from there.
"What were trying to do now is move away from the grid," explains White. "The standard TV listing is a very dated navigation paradigm, one that hasnt really changed since the 1960s. So were bringing together all available content, including over the air, Video on Demand and catch-up. The guides not time based because no one watches that way anymore."
In addition to LG, Gracenotes parent Sony, along with Philips TP Vision, Loewe and OEM giant Vestel are all introducing variations of the system.
"One of the things were doing for Philips is providing a personalised recommendation platform, based on a user profile," reveals White. "We can push things to the front of its guide interface that we know you care about, and push things away that we know you dont."
The algorithm fuelling this knowledge is based on the content descriptors in Gracenotes metadata. "We know things about the show, as you watch it. We can also deliver ads while you browse – the primary engine for all this is content comprehension..." Your device will look for an audio fingerprint to find out what youre watching
Content comprehension
Demonstrations of On Now are certainly compelling, but this is just the start of what Gracenote believes will be an extraordinary change in our relationship with the boob tube.
The company has perfected an Automatic Content Recognition (ACR) platform, known internally as Entourage, which utilises audio fingerprinting to literally monitor what youre watching.
Taking advantage of the built-in microphone in tablets and smart phones, its able to identify a TV show via snippets of dialogue and soundtrack. Its similar in some respects to rival wizardry from Shazam, but with an added important talent for synchronization.
"The idea is that the client on your mobile device is running a Classifier within an app, which listens to the audio or music on a TV show, then cross references it with our database." Entourage works with any content, says White. "Right now were covering something like two hundred channels in the US, a 100 plus in Europe and 14 in Japan."
Gracenote creates the fingerprints through listening stations around the globe. "Were listening to content as its being broadcast, fingerprinting it and marrying it up to EPG data." Sony is preloading the technology on the Xperia Z1, dubbing it Track ID TV. The new EPG is note organised according to time like a standard system
Whats on
In the US, Entourage ARC provided the interactive backbone to hit game show The Million Second quiz. "Its an industry first," says White. "The studio integrated Entourage synchronisation into the official show app, allowing the audience to play along in real time."
The audience was given exactly the same amount of time to answer the questions as the contestants. High scorers were then brought into the studio to compete the next night. "The idea is to get the best players from the entire audience competing. Its never been done before."
White says theres been a surge from the creative community to leverage the technology, citing NBC Universals SyFy channel as one of the more inventive.
The channel created a companion app for its Face-Off visual effects reality show that syncs with the viewer as they watch and unlocks additional behind-the-scenes content as the show progresses. NBC Universal also used Entourage to serve viewers of Sci-fi holkum Haven an alternative episode ending on their companion device.
However the most contentious development of the technology is yet to come. Gracenote is on the verge of trialling video fingerprinting. For the first time, it will be the TV itself actively monitoring what youre watching, not a companion app. And youll probably not realise its doing it.
The video fingerprinting tech is embedded in the TV itself, reveals White. "It takes live video out of the video buffer, compares it against our database and then fingerprints it. This effectively allows the TV to recognise what shows youre watching."
The system is extraordinarily powerful. Most significantly, it allows Gracenote to profile TV usage, allowing the company to learn specific things about your household.