Android Studio Live Templates Usage Examples

Android Studio, IDE offered by JetBrain, helps your day if you know how to use it more and more. Continuing from live template introduction, I introduce some examples of custom live templates which I found it convenient to use during my Android app development. To add your custom live template go to [File] → [Settings] → Select [Editor] category, [Leve Templates] → On the right side, you can add your custom template to “user” category. Click + button → [1. Live Templates]. 1. dump – check variables value for debugging Abbreviation: dump Description: print log to check variable’s value Template text:

Set applicable contexts to “Java” language. Template variables It is useful when you […]

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 →

Javadoc coding rule of @link, @linkplain, @see

How to write link reference in javadoc See previous post for general javadoc explanation. Basic rule To show “label” which refers to other field class/method/member, where “label” is optional..

Example,

Here, package name is omitted. You can use omitted name to avoid writing long sentences. Below is the list of how you can write links. 1. Refer current class member

When you refer current class member, it is possible to omit writing Package.class. 2. Refer current class or imported package’s other class 

When you refer member which is in current class or imported package’s class, it is possible to omit writing Package. 3. Refer other package’s member

You must […]

Continue reading →

Get to know coding rule of Javadoc in 10 mins

Javadoc – Java document comment Javadoc is used in Java language to write comment with the format stats from “/**” (2 asterisk needed) and ends with “*/” 

 It is used as a explanation document for the program which is embedded in source code. Usually, Brief explanation of Class, method, and member can be written as Javadoc format. If the Javadoc was written, we can also auto generate HTML type documentation file, for example see Java Platform SE API reference page.   HTML TAG HTML tag can be used to write Javadoc, which makes it formatted document and easy to refer. When you use IDE like Eclipse or Android studio, explanation is […]

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 →

Cannot use Software keyboard after pairing with TV SideView on SONY BRAVIA Android TV

Software keyboard cannot be launched and I cannot type from TV When I was using SONY’s TV SideView application, I faced a problem after pairing with TV SideView on SONY BRAVIA Android TV. I could not type any alphabet from TV, it always ask me to type from paired mobile with the word “Use the keyboard on your mobile device.“.  Even Solution: check Android system Keyboard setting The cause was coming from the Current keyboard setting has changed. You can change it by going to [Setting] → [Keyboard] (on System Preferences row) → [Current keyboard]. When “Virtual Remote keyboard” was selected, it was the root cause. Change it to the other. Leanback […]

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 →