Year: 2013

Blog Summary of 2013

2013-12-31 Uncategorized No comments

In the beginning of 2013 I decided to re-launch my modest blog in order collect some experiences, thoughts and share knowledge.
I managed to publish 38 posts. Some of them were only links, but there were also tutorials, solutions for common problems, information about conferences and so on. I haven’t published everything I wanted to publish due to lack of time, which was limited by studies and work. Fortunately, I managed to publish, more or less, at least one post per month with a few exceptions. I’ve got 32 drafts of posts and a few ideas for projects and articles. I hope, that quality and value of my posts is growing, so you can find better articles here in New Year. There was also small interaction with users. I got 10 comments to my posts. If you want, to ask about something or post a suggestion, don’t hesitate and write a comment. My blog has about 4018 visits and 3179 unique visitors in whole year. It’s not that much, but I hope, that people, who was searching for interesting information and solution for their problems have found, what they wanted. Number of visitors is constantly growing, what can be seen on the graph generated by Google Analytics, which you can check below (click on the image to enlarge it).
visits_in_2013
The most of my visitors were from Poland. It’s not surprising, because it’s my home country. Second country, from which people visit my blog, is India. United States of America is on the 3rd place. Germany takes 4th place and South Korea takes 5th place. When, we take into consideration cities, first place goes to Katowice (Poland), second is not set (undefined), third is Bangalore (India), fourth – Seoul (South Korea), fifth is Gliwice (Poland) – my hometown. 80% of visitors are new (visiting website for the first time), 20% of visitors are returning. Interesting thing, is the fact, that I got at least one visitor from almost all around the world (some of them were internet bots or crawlers, but there were a lot of real users). Check out the map below.
visits_in_2013_countries
Most of my posts were connected with software development and Android due to my current work and master thesis at university. Probably, future posts will be also connected with these areas, but I’m constantly trying to broaden my mind, so you may find here also articles concerning totally different topics. I hope, you’ll keep visiting this blog and you’ll find interesting articles and materials here. I’m going to do my best in order to improve quality of the posts and publish interesting and valuable articles here. I wish you all the best.

Happy New Year and see you in 2014!

JDD Conference 2013

2013-10-12 Conferences, Java No comments

JDD 2013

In the beginning of the next week, there will be interesting conference connected mostly with Java technology in Kraków, Poland. Lectures and workshops will be performed both in Polish and English language. Topics are not only connected with Java. We will be able to hear something about Big Data processing, front-end development, mobile development, Scala, design patterns, software architecture, Domain Driven Design and so on. It’s large amount of topics, so everyone should find something interesting for him or her.
See you there on Monday!

How to connect to Android device via TCP/IP?

2013-10-12 Android No comments

While developing Android applications, we need to debug them on real devices. We also should be able to access debug output and execute Unix shell commands. In Android device (mobile phone or tablet), we can go to Settings and then to Developer options. Afterwards, we can enable USB Debugging. Now, we can connect our device via USB cable to the computer and we will be able to access it via Android Debug Bridge (ADB). USB connection is standard way of debugging application on real devices. We can also use TCP/IP connection and debug applications wireless. In order to do that, we need to go through the following steps:

  1. Activate USB debug mode in Android device (it’s described above)
  2. Connect Android device to computer via USB
  3. Open command prompt (With Admin Right) and type: adb tcpip 5555 (note #1: in Windows OS, you need to have platform-tools directory from Android SDK directory assigned to system variable Path; note #2: 5555 is number of port we will be using)
  4. Disconnect your tablet or smartphone from computer
  5. Open command prompt type: adb connect IPADDRESS (IPADDRESS is the DHCP/IP address of your tablet or smartphone, which you can find by going to: Settings » About device » Status » IP address)

Now, you can use adb commands. E.g. adb shell or adb logcat. If you want to list connected devices or check if any device is connected to your computer, you can use command: adb devices.
Note #1: You shouldn’t use TCP/IP and USB debugging mode at the same time.
If you want to return to USB debugging mode, just connect your device to the computer via TCP/IP and then type: adb usb. After that, connect device to the computer via USB cable and you will be able to debug applications via USB connection again.
Note #2: In Android Studio you can use built-in terminal window instead of standard command prompt.
Note #3: Alternative way of returning to default debug mode (USB) is resetting the phone. You can simply turn it off and then turn it on and device will be in USB debug mode again.

Android stuff you probably want to know about

2013-09-09 Android No comments

I’ve recently found interesting post about Android stuff you probably want to know about. It isn’t the newest resource, but it’s still up to date. Chceck this out:

DevDay 2013 Conference, 20th September, Kraków, Poland

2013-09-08 Conferences No comments

DevDay 2013

DevDay Conference is going to be organized on 20th of September 2013 in Kraków, Poland. When we take a short look on the agenda, we can conclude, that it’s going to be very interesting event with talks covering many areas of software development and programmers lifestyle. In addition, invited speakers represent famous brands like Google, Spotify, StackOverflow, JetBrains and so on. In my opinion, we can expect very high quality of the talks. DevDay 2013 is organized by ABB Poland. Fortunately, I’ve already passed registration process some time ago, so see you there!

Justifying block of text inside TextView in Android

2013-08-31 Android 15 comments

Justifying text inside TextView in Android is not that simple as we may expect it to be. Unfortunately, Android does not have attribute for TextView, which supports justifying text. We can set alignment to the right or to the left, but we cannot simply justify text with generic attributes. In order to do that, we need to perform a few tricks.

First of all, we need to create file named justified_textview.css and we need to put it into the assets/ directory of our project. We will use it later in our custom view. Source code of this CSS stylesheet is presented below:

Next, we need to create class for customized view extending WebView. Let’s call it JustifiedTextView.

After that, we need to update res/values/attrs.xml file and put inside the following declaration:

Now, we are ready to use our custom JustifiedTextView.
In order to do that, we need to create layout containing JustifiedTextView as follows:

Next, we can access JustifiedTextView in our activity:

We can also set text inside XML layout instead of doing this programmatically. It depends on our project.

We also should turn off hardware acceleration for given activity in AndroidManifest.xml file in order to bring this solution to work.

That’s it. It’s not perfect solution and it’s kind of workaround, but I haven’t found any better idea how to deal with this problem.
I tested a few solutions and this one is, in my opinion, the best available and most elegant option for now.

Please note: There may be a problem with proper execution of this solution on Android OS version lower than 3.0 (API 11).

If you know any better ideas, how to deal with this problem, please let me know about that in comments below this article.

Asynchronous loading and caching bitmaps with Volley

2013-08-26 Android 3 comments

As I mentioned in previous post, we can use Volley library from Google for very clean, simple and easy loading of the images from Internet.
Volley uses LRU cache, so first of all, we need to create BitmapLruCache class extending LruCache class.

Next, we need to create VolleyHelper class.

Then, somewhere in our activity, we can use the following code snippet:

As we can see, we can define image in case of error or no image.
What is nice and important, Volley will take care of asynchronous downloading of the bitmaps, so we don’t have to create additional AsyncTasks. It will also create cache in temporary memory and on disk with using LRU cache.

As we could easily notice, Volley is really good and small, but powerful library, which can make our life easier. It was also created and tested by Google, what assures its stability and quality.

Simple Android Networking

2013-08-22 Android No comments

I’ve recently found an interesting article about Simple Android Networking by Teehan+Lax where you can find easy way of handling network requests, JSON data and images. Described Volley library released by Google also takes care of caching data and memory performance. Linked article is based on: Google I/O Volley Talk.

How to change Fragment layout on orientation change?

2013-08-15 Android 8 comments

When we work with Activities in Android, defining different layouts for different screen orientations is easy. The only thing we need to do, is to create two *.xml files with the same name for layouts in two separate directories (res/layout/ and res/layout-land/). In Fragments it’s not that easy. In such case, we need to perform additional operations in order to achieve our goal.
Fragment in Android is not re-inflated on configuration change, but we can recreate layout and repopulate view manually.
We need to create two layouts for different orientations of the screen in the same way as for Activity:

  • res/layout/my_fragment.xml
  • res/layout-land/my_fragment.xml

Then, we need to put code shown below to our fragment.
Of course, it requires little adjustments depending on concrete project.

That’s it!

Clean Code Cheat Sheet

2013-08-11 Software Development No comments

Recently at BBV Software Services blog I have found very interesting and handy Clean Code Cheat Sheet, which can help you to be better programmer. This document is actually based on famous book Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin.
clean_code_cheat_sheet
Clean-Code-V2.1