background preloader

2014

Facebook Twitter

Rest interaction in Android. In last December ('13) I was asked to submit a talk proposal for the first Italian Droidcon, which I did.

Rest interaction in Android

It got accepted, so in Febraury I gave my first public speech speaking of "(O)Authenticated Rest Interaction in Android" in front of real people. This post is meant to be a follow up with the information that can't be found in the slides I hoped to sum all the talk up in a post, but it got too long so I am going to split it in several pieces.

This one will cover the asynchronous interaction with a remote webservice. Disclaimer: I am not inventing anything new here, most of the content can be found on the internet. Rule #1: decouple the interaction with the web service from UI components (activities / fragment) There are several reasons for that. You should start thinking that any network operation has a cost, in terms of bandwith and cpu power. Consume Webservice in Android using intentService. Topics covered Consume Webservice in Android IntentService ResultReceiver In this post, I will explain how to consume Restful Webservice using IntentService.

Consume Webservice in Android using intentService

Modern techniques for implementing REST clients on Android 4.0 and below – Part 2 - neilgoodman.net. This is the second and last part of a tutorial on implementing REST clients using modern APIs introduce in Honeycomb and Ice Cream Sandwich.

Modern techniques for implementing REST clients on Android 4.0 and below – Part 2 - neilgoodman.net

In the last part of this tutorial I covered how to make REST calls using Loaders and the LoaderManager class. In this part of the tutorial, I will be covering how to make REST calls using Services and the motivations behind this approach. Why use a Service? The Loader approach worked well last time. LoaderManager has a very simple API and it manages the state of Loaders so that they are released and restarted when they need to be. This short lived behavior may not be bad for your application. What is Context in Android - SimpleCodeStuffs. Context is context of current state of the application/object.It€™s an entity that represents various environment data .

What is Context in Android - SimpleCodeStuffs

Context helps the current activity to interact with out side android environment like local files, databases, class loaders associated to the environment, services including system-level services, and more. A Context is a handle to the system . It provides services like resolving resources, obtaining access to databases and preferences, and so on. Context, What Context? - by Dave Smith of Double Encore. Context objects are so common, and get passed around so frequently, it can be easy to create a situation you didn’t intend.

Context, What Context? - by Dave Smith of Double Encore

Loading resources, launching a new Activity, obtaining a system service, getting internal file paths, and creating views all require a Context (and that’s not even getting started on the full list!) To accomplish the task. What I’d like to do is provide for you some insights on how Context works alongside some tips that will (hopefully) allow you to leverage it more effectively in your applications. Context Types Not all Context instances are created equal. Handling Runtime Changes. To test that your application restarts itself with the application state intact, you should invoke configuration changes (such as changing the screen orientation) while performing various tasks in your application.

Handling Runtime Changes

Your application should be able to restart at any time without loss of user data or state in order to handle events such as configuration changes or when the user receives an incoming phone call and then returns to your application much later after your application process may have been destroyed. To learn how you can restore your activity state, read about the Activity lifecycle. However, you might encounter a situation in which restarting your application and restoring significant amounts of data can be costly and create a poor user experience. In such a situation, you have two other options: Romannurik/Android-WizardPager. AndroidDev people you should follow. Andersgoransson/eatbookexamples. Services. A Service is an application component that can perform long-running operations in the background and does not provide a user interface.

Services

Another application component can start a service and it will continue to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC). For example, a service might handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background. Android : Volley and Gson tutorial. Android Volley is the new way to make network requests.

Android : Volley and Gson tutorial

It has a lot of advantages : configurable thread pool, request priority, caching, request cancel. AsyncTask is no more needed and this is a good new as AsyncTask is known for its memory leak issues. In this quick step tutorial, i show the piece of source code to make it work with google gson library. Test before If you wish to test before, you can install the application with the following link. The whole source code of the project is also available on github. Android Bootstrap. AndroidBootstrap/android-bootstrap. Your app idea. Si vous voulez simplement lire le code , consulter des extraits ou des solutions fraîches sur - le - aller puis le code Peeker est pour vous!

Your app idea

C'est un super petit lecteur de code (note : pas lire, pas un éditeur ) qui améliore la connaissance de codage actuel en mettant en évidence votre expertise codage passé. Avec le code Peeker vous pouvez partager des astuces de codage de réussite lors d'une entrevue d'emploi ou de réunions . Ça va vous faire paraître beaucoup mieux que de promettre «Je ne sais pas. Libraries to use for easy asynchronous REST web requests and image loading. Asynchronous HTTP requests in Android using Volley - Arnab Chakraborty. Volley is the new Swiss Army Knife of Android Developers, it provides some nice utilities which makes the networking for Android apps easier and faster.

Asynchronous HTTP requests in Android using Volley - Arnab Chakraborty

The good thing about Volley is that it abstracts away the low level details of what HTTP client library is being used under the hood and helps you focus on writing nice and clean RESTful HTTP requests. Additionally all requests in Volley are executed asynchronously on a different thread without blocking your “main thread”. What are the features that Volley provides? Important features of the Volley library: A high level API to make asynchronous RESTful HTTP requestsAn elegant and robust Request queueAn extensible architecture which allows developers to implement custom request and response handling mechanismAbility to use external HTTP client libraryRobust request caching policyCustom views to load and cache images from Network (NetworkImageView, ImageLoader etc)

Robospice/dependencies/1.4.12 at repository · stephanenicolas/robospice. Gson User Guide - gson. Serializing and Deserializing Collection with Objects of Arbitrary Types Sometimes you are dealing with JSON array that contains mixed types. OkHttp. Overview HTTP is the way modern applications network. It’s how we exchange data & media.

Doing HTTP efficiently makes your stuff load faster and saves bandwidth. OkHttp is an HTTP client that’s efficient by default: HTTP/2 support allows all requests to the same host to share a socket. Retrofit. Introduction Retrofit turns your REST API into a Java interface. public interface GitHubService { @GET("/users/{user}/repos") List<Repo> listRepos(@Path("user") String user);} The RestAdapter class generates an implementation of the GitHubService interface. RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint(" .build(); GitHubService service = restAdapter.create(GitHubService.class); Each call on the generated GitHubService makes an HTTP request to the remote webserver.

List<Repo> repos = service.listRepos("octocat"); Gson User Guide - gson. The Central Repository Search Engine. Saving (and Retrieving) Android Instance State - Part 1 - Intertech Blog. Why do we need to save instance state? Android activities have a lifecycle (for a diagram of this lifecycle see here). As an activity becomes partially hidden (paused) or fully hidden (stopped), possibly even destroyed, your applications need a way to keep valuable state (i.e. data) the activity has obtained (probably from user input) or created even after the activity has gone away. As an example, an orientation change can cause your activity to be destroyed and removed from memory and then recreated again. Unless you avail yourself to certain state saving mechanisms, any data your activity has at the time of orientation change can be completely lost in this seemingly simple act.

Android and REST. Path/android-priority-jobqueue. Nlefler/NLFoursquare-Android. Thunsaker/soup. Condesales/easyFoursquare4Android. Path/android-priority-jobqueue. Google I/O 2010 - Android REST client applications. Implementing Loaders (part 3) This post introduces the Loader<D> class as well as custom Loader implementations. This is the third of a series of posts I will be writing on Loaders and the LoaderManager: First things first, if you haven’t read my previous two posts, I suggest you do so before continuing further. Here is a very brief summary of what this blog has covered so far. Life Before Loaders (part 1) described the flaws of the pre-Honeycomb 3.0 API and its tendency to perform lengthy queries on the main UI thread. These UI-unfriendly APIs resulted in unresponsive applications and were the primary motivation for introducing the Loader and the LoaderManager in Android 3.0.

Android Fundamentals: Properly Loading Data. The UI thread is a bad place for lengthy operations like loading data. You never know how long data will take to load, especially if that data is sourced from a content provider or the network. Android 3.0 (Honeycomb) introduced the concept of Loaders and, in particular, the CursorLoader class that offloads the work of loading data on a thread, and keeps the data persistent during short term activity refresh events, such as an orientation change. We'll incorporate the Loader as a new feature in our ongoing tutorial series building a yet-to-be-named tutorial reader application. If you were paying close attention to our last tutorial, Android Fundamentals: Working With Content Providers, you may have noticed that we took a shortcut. We used the managedQuery() method of the Activity class, which is a newly deprecated method. Android Components. The CommonsWare Android Components, or CWAC, are open source libraries to help solve various tactical problems with Android development.

Loading Data in the Background. Android Fundamentals: Properly Loading Data. RoboSpice presentation. Android Background Processing with Handlers and AsyncTask and Loaders. Loaders. Android: Loaders versus AsyncTask. One of the biggest pieces of Android that I have neglected to learn about would be Loaders. RoboSpice-InfoGraphics.png (600×5417) Note1. Demonstrate HTTP caching with OkHttp and Retrofit. Creating a REST library using Retrofit & OkHttp. I've been tasked to modernize our application's networking layer. We have been writing our own network manager to deal with http 302 redirect and caching responses, but there are many opensource project that already does these things very well.

Android Async HTTP Clients: Volley vs Retrofit - Instructure Tech Blog. We recently released a new version of our mobile app for Android. Although it was a huge improvement from previous installments in terms of features, design, and usability, there was one nagging issue in the back of our minds: speed. There are times when the app isn’t as snappy as we’d like it to be. After some profiling, benchmarks, and common sense, we determined that retrieving data from the API (the networking) was the bottleneck. The Old Way: AsyncTasks. Android Networking Without the Pain de Colin Lee en Prezi. Android RoboSpice with GoogleHttpClient. Stephanenicolas/robospice. RoboSpice Motivations - Aplicaciones Android en Google Play. Join the G+ community and register as a tester to get latest alpha/beta versions: Andlytics collects statistics from the Google Play Developer Console.

It lets you track active installs, total installs, ratings, and comments for all your Android apps that are published on Google Play. Andlytics can also collect AdMob statistics, including revenue, requests and impressions. Handling Runtime Changes. SpiceManager in Application · Issue #211 · stephanenicolas/robospice. Greenrobot/EventBus. Announcing OkHttp. May 06, 2013. Square/okhttp. AnawazInc/OkHttp-Picasso-Example-Android. Comparison of Android Networking Libraries: OkHTTP, Retrofit, Volley.