Building adb and fastboot command from AOSP source code

adb, android debugging brige, is used for connecting your PC and Android devices to get log, send command to Android devices etc which is very useful for Android software development. fastboot command is used to control bootloader mode for Nexus devices, it can be used to flash new factory image etc. Here the method of how to build adb command and fastboot command manually from Android Open Source Project source code is written. If you feel it trouble some to build adb and fastboot command manually in your PC, see also The Easiest Way to Install Android’s ADB and Fastboot Tools on Any OS [Guide] How To Setup And Use […]

Continue reading →

AsyncTask implementation framework – to be independent from Activity –

Continuing from AsyncTask usage summary. Interest is how to establish independence between Activity and AsyncTask? The answer is well summarized in the article, “Android AsyncTask はバックグラウンドの処理に集中すべし!”. I will just translate and re-summarize this article. 3 ways will be introduced.  Advance – implementation framework of AsyncTask A. Define as inner class of Activity Most intuitive, easy and faster way is to implement your AsyncTask inside Activity which use it. It is nice choice when CustomAsyncTask is specific (highly dependent on) to the parent Activity. Mock implementation is like below, here text of mEditText is updated after AsyncTask’s background process.

The problem is that member of Activity, mEditText, is used inside onPostExecute() method of CustomAsyncTask. […]

Continue reading →

Spinner Fragment: show loading progress bar
– Android TV app hands on Tutorial Appendix A

spinner-2015-09-17-111126

In the Appendix of this Tutorial, I will introduce useful Android common library/function. These are usually applicable not only for Android TV, but also for Android phone/tablet device as well.   Spinner Fragment – show loading progress bar While user is downloading big contents from web, you might want to show progress bar to notify user that some process (in this time downloading) is being done in background. It helps navigating user to wait this process. Here, SpinnerFragment can be used to show circle arrow progress bar. Starting by making class by right click on “ui” package → [New] → [Java Class] → put Name as “SpinnerFragment”. This class is a subclass of […]

Continue reading →

Refactoring source code construction
– Android TV app hands on Tutorial 14

Refactoring I have explained Android TV specific UI implementations (sample source code referenced from Android TV sample application) through this tutorial. So I conclude this project by reorganizing the source code files. I did refactoring based on the role of each classes, and finished with below structure. com.corochann.androidtvapptutorial common – common functions. This module has no dependency of this application’s specific implementation so that you can “re-use” the code in other project as well.  PlaybackController Utils data – the data set of “Model” MovieProvider model – “Model” part of MVP architecture Movie recommendation – Recommendation function part RecommendationBuilder RecommendationFactory ui – UI handling modules (Activity & Fragments) MainActivity & MainFragment DetailsActivity & […]

Continue reading →

Build executable file with Android NDK after Lollipop (Android API 21)

I’ll introduce more functionality of Android NDK continuing from Android NDK set up introduction. Android NDK is not only a tool to build up .so library to call through JNI, but it is also possible to build executable file itself. It is achieved by just changing Android.mk configuration.  Below is example implementation to build hello-exe file. 1. Write Native (C/C++ language) source code Make “hello-exe” folder anywhere and inside this folder make “jni” folder. Place “hello-exe.c” in “jni” folder and write following. So we have a folder construction like hello-exe/jni/hello-exe.c.

For this tutorial, it is enough for native source code implementation 2-1. Build configuration by Android.mk (Before Android L) Write Android.mk […]

Continue reading →

Starting Android NDK is easy!

Android NDK Develop environment set up summary Usually Android application is developed by Java, but you can use C/C++ source code together with Android NDK (Android Native Development Kit). It provides us a opportunity to re-use/integrate existing C source code as well. Below is summary for the steps how to start working with Android NDK. Step1. Download installer from official site Visit download site here, and choose installer depending on your development OS platform. In my case, I was working on Windows 7 64-bit OS, I chose android-ndk-r10e-windows-x86_64.exe. Step2. Execute installer  Double click to execute downloaded installer(.exe file in Windows case). It will just automatically extract the files to construct NDK working directory set. It takes […]

Continue reading →

Android Studio Live Templates Introduction

live_template_1

How to use Live Templates Go to [File] → [Setting] → [Live Templates], already registered live templates are shown. We can check the Abbreviation, Description and Template text here. During the coding, typing “Abbreviation”(shorcut command) followed by pressing [Tab], “Template text” will be expanded. Live templates are very useful to eliminate to write the code which we often use. For example, Abbreviation “fbc” can be used for coding findViewById method (You definitely often use it when you want a reference to UI, right?). Type “fbc” and press Tab, it will automatically expand

and the cursor is selected to inside the first (), so that you can start typing class […]

Continue reading →

In-app Search function implementation
– Android TV app hands on Tutorial 13

Search function implementation The usage of SearchFragment of Leanback support library and UI related implementation are explained in previous chapter. In this chapter, I will explain (background) search function logic. Most of the implementation in this chapter is just a explanation of googlesamples. In-app search algorithm Search algorithm is implemented in loadRows method, especially the main logic is in doInBackground method of AsyncTask. It is actually simple, just checking the string “query” is contained in either title or description of Movie items. The UI related task Adapter handling is done in UI thread. onPreExecute initializes mRowsAdapter, which will contain the search results, by clear method. Searching itself is executed in background thread in […]

Continue reading →

AsyncTask usage summary

AsyncTask01

Overview AsyncTask is useful when you are working on UI (main) thread, and want to do some (maybe long) background process, and want to get callback after the background process finishes. For example, consider the case when you want to update UI of Activity according to the result of internet access. You must execute URLconnection in background thread, while updating UI must be done in UI thread after getting result. It can be implemented without caring about threads or handlers by using AsyncTask.  Basics 4 Steps method execution flow onPreExecute: invoked on the UI thread, before doInBackground starts. Initial set up part. doInBackground: invoked on the background thread. Long computation/process (ex. downloading) is executed in […]

Continue reading →

SearchFragment
– Android TV app hands on Tutorial 12

search3-2015-09-02-210633

In-app Search on Android TV application One of the biggest difference between Android phone & Android TV is their input method. Since TV does not support touchpad, and we shouldn’t expect users to use keyboard for TV, inputting words for TV is troublesome. Google suggests to use voice input for in Searching within TV Apps   In-app Search icon on BrowseFragment BrowseFragment contains a design layout for search function as well, and showing in-app icon on your application is very easy. Just implement setOnSearchClickedListener, that’s all.

setSearchAffordanceColor method can be used for specifying search icon color.

    SearchFragment Search function need to be implemented to answer user’s search query. To show […]

Continue reading →