background preloader

Android learning

Facebook Twitter

A Smart Way to Use Retrofit - Android Tips and Tricks. Retrofit library is a type-safe REST client for Android and Java created by Square Open Source.

A Smart Way to Use Retrofit - Android Tips and Tricks

With this library you can request the webservices of a REST api with POST, GET and more. This library is awesome and very useful, but you need a good architecture and a good practice to use it as best as possible. Pushing the ActionBar to the next level. Back in November 2012, I wrote a blog post entitled “ActionBar on the Move”.

Pushing the ActionBar to the next level

This article was mainly dealing with a technique to nicely and uniquely animate your ActionBar. Although I mentioned some of the effect’s possible applications, I never had time to effectively add an ActionBar animation to one of my own apps nor saw an application on the Play Store taking advantage of it. Butter Knife. Introduction Annotate fields with @Bind and a view ID for Butter Knife to find and automatically cast the corresponding view in your layout. class ExampleActivity extends Activity { @Bind( TextView title; @Bind( TextView subtitle; @Bind( TextView footer; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_activity); ButterKnife.bind(this); // TODO Use fields... }} Instead of slow reflection, code is generated to perform the view look-ups.

Butter Knife

Calling bind delegates to this generated code that you can see and debug. The generated code for the above example is roughly equivalent to the following: Loosely coupled In-app communication in Android – Mickael's Android Playground. When designing an application, I had a problem with my fragments’ interaction.

Loosely coupled In-app communication in Android – Mickael's Android Playground

I decided to let my activity hold every information important to my Application, and let the fragments access those data directly via the Activity. The problem is that Fragments and Activities aren’t supposed to be that tightly coupled. A fragment is supposed to be independent from its activity lifecycle, and we’re going to see why… Dmytro Danylyk - Portfolio. What is boiler code?

Dmytro Danylyk - Portfolio

In computer programming, boilerplate code or boilerplate is the sections of code that have to be included in many places with little or no alteration. What are templates? Live templates let you insert frequently-used or custom code constructs into your source code file quickly, efficiently, and accurately. Simple server-client syncing for mobile apps using Couchbase Mobile — Infinum. View inflation vs visibility:"GONE": a battle fought with DDMS – Mickael's Android Playground. A few days ago, I struggled with a simple use case: in an Android Application, I wanted to show a simple tutorial item (displayed as a Card View), but only until the user acknowledged he knew how the app works.

View inflation vs visibility:"GONE": a battle fought with DDMS – Mickael's Android Playground

To do so, I first decided to put this simple view in my layout with a visibility of GONE, and changing its visibility based on a SharedPreference item telling if the user knew how the app worked. This solution was simple enough, but I was wondering, wouldn’t it be bad for performance if we need to inflate a view that will never be shown? So, the other solution I thought about was to inflate this view only when the user open the app for the first few time.

This would require to do the inflation programmatically, which requires to call inflater.inflate twice, and might be even worse in term of performances. Android working with Volley Library. Effects of Android Application Termination. Between process management of the system at large and user behavior, there are a handful of methods through which your Android application process may terminate.

Effects of Android Application Termination

The additional effects on your application code (based on the method) may have consequences for you as a developer. Android’s Notification Center - Android - issue #11. Notifications from our devices are almost second nature for us these days.

Android’s Notification Center - Android - issue #11

Hardly an hour goes by that we aren’t pulling out our phones, checking our status bars, and then putting our phones back in our pockets. For Android users, this is especially true, as it is one of the primary ways of interacting with their devices. Unlock your screen, read a few emails, approve some friend requests, and like your buddy’s check-in, across three different applications, all directly from the notification bar. But this is an entirely different world for some. Particularly, iOS has a long history of not getting notifications quite right, and iOS developers didn’t have the same kind of fine-grained control over their apps’ notifications.

It’s been long touted that Android ‘got’ notifications right from the beginning. Since Android let developers fully control their own background processes, they were able to create and show notifications at any time, for any reason. A Brief History. Complete_android_fragment_lifecycle.png (PNG Image, 1196 × 2552 pixels) Hands on Retrofit (A Rest Api Client) – s3xy4ngyc Dev Journey. Introduction When it comes to networking, there are tons of ways to do the requests.

Hands on Retrofit (A Rest Api Client) – s3xy4ngyc Dev Journey

Most of the time you will end up with a lot of boilerplate code, or endless scripts containing transformations and stuff into useable code. Actually there’s a smarter way of doing that, namely by using some frameworks. As a result you’ll find your code sexy and easy to understand and maintain again. What will be using? In order to keep everything simple, we will be using these neat tools: Gradle: The new Android build tool. Basicly, there are many libraries that do the same job.

Getting Started First of all, I made commits for every step of this hands on, so that you can checkout certain steps, and follow on by coding. Clone the Repository hosted on github: git clone I’ve made an initial commit after creating a basic application without any dependencies and stuff. Adding Dependencies to Gradle Since we are using Gradle, we can easily add libraries to the project, by defining dependencies. Requesting the API. Google I/O 2010 - Android REST client applications.

Android advanced android interview questions and answers paper 16. SimpleExample - roboguice - A brief example of what RoboGuice does - Google Guice on Android, version 2.0. RoboGuice is a framework that brings the simplicity and ease of Dependency Injection to Android, using Google's own Guice library.

SimpleExample - roboguice - A brief example of what RoboGuice does - Google Guice on Android, version 2.0

If you've ever used Spring (the #1 enterprise framework on Java, now more popular than J2EE itself) or Guice, you already know how convenient this style of programming can be. Service - Android SDK. Note that services, like other application objects, run in the main thread of their hosting process. This means that, if your service is going to do any CPU intensive (such as MP3 playback) or blocking (such as networking) operations, it should spawn its own thread in which to do that work. More information on this can be found in Processes and Threads.

The IntentService class is available as a standard implementation of Service that has its own thread where it schedules its work to be done. Topics covered here: Developer Guides. 14 Great Android apps that are also open source. 15 Online Courses To Make You An Android App Developer. Mastering Android Programming by Vishal Lamba.