Api, OkHttp, Picasso, RecyclerView ebook tutorial, httpYou can grab the power of Flickr, Youtube, Twitter and thousands of other powerful online applications, presenting their data from within your apps. We’ll show you how with this simple, easy to follow tutorial app.

Our tutorial shows you how to use an image repository’s API’s to access their image gallery.

We also show you how to use the OkHttp library to do network uploads, downloads and queries.

Finally, we also show you how to use the Picasso library to download, cache and display images in a RecyclerView widget.

What you’ll learn?

  • Using API’s to increase the power of your apps
  • Using OkHttp to:
    • Upload an image
    • Download an image
    • Search the Imgur gallery for images
  • Using Picasso to download and display the images found
  • Using RecyclerView to display the images for Picasso
  • Working with Json

PLUS

An introduction to:

  • API’s
  • HTTP

PLUS

Lots of links to useful tutorials and documentation covering Imgur, Json, Api’s, Http, OkHttp, Picasso and RecyclerView.

Get the eBook PLUS the code for only US$ 1.49

 

Android: Launching activities

Launch Mode

Android launchMode launchMode icon

The launch mode specifies how a new activity should be associated with the current task.

Before trying to make sense of this, let’s first have a look at:

  • the Back Stack
  • and Tasks

Get in touch and stay in focus

Android Touch Mode and focus icon

So what’s Touch Mode?

Users can interact with their Smart Android devices using hardware keypads and buttons or by touching the screen.

Touching the screen puts the device into touch mode. The user can then interact with it by touching the on-screen virtual buttons, images, etc.

The device remains in touch mode across activities until the user exits touch mode.

Touching a hardware button causes the device to exit touch mode.

You can check if the device is in touch mode by calling the View class’s isInTouchMode()  method.

So what’s focus?

A view or widget is usually highlighted or displays a flashing cursor when it’s in focus. This indicates that it’s ready to accept input from the user.

Focus is necessary for devices using trackballs, styluses, external keyboards and hardware buttons so that the user can see which view is ready to receive input.

Focus is not necessary when the device is in touch mode.

What a partnership! Picasso and RecyclerView

Android RecyclerView and Picasso tutorial icon

If you display images in lists or grids then you should consider using Picasso and RecyclerView.

Picasso is a powerful image downloading and caching library package which you include in your app build. It simplifies working with images, reducing the code that you need to use to one line of code.

Picasso is fast and easy to use and it’s FREE!

The RecyclerView widget is essentially a container that you can use to display large sets of data. It’s very efficient as it only displays a few items at a time. Views that are no longer needed are recycled and reused.

Not having to keep on inflating views saves CPU resources and valuable memory is saved by not having to keep views alive in the background.

Combine Picasso and RecyclerView and your app will move at the speed of light!

Using the OkHttp library for easy downloading

Android cloud connection OkHttp http icon

Want to simplify communicating with the cloud?

More and more mobile apps are making use of data storage in the cloud. Android provides the tools to communicate with the cloud but it takes quite a bit of coding to make it work.

OkHttp is a popular library that reduces the amount of code, making it very easy for you to make use of cloud storage for your app.

OkHttp is developed by Square and is FREE!

Using custom fonts

Android custom fonts icon

The Android SDK comes with a set of fonts but you can also use your own fonts.

We’ll show you how.

Passing Parcels between activities

Android Parcelable interface tutorial icon

You can pass primitive data, like integers, strings, booleans and array lists between activities.

You can also pass Serialized object between activities. We showed you how in a previous tutorial. In this tutorial, we show you how to use the Parcelable interface to pass objects between activities.

Passing Serialized objects between activities

Android Serializable objects icon

You can pass primitive data, like integers, strings, booleans and array lists between activities.

You can also pass Serialized objects between activities. We’ll show you how.

RecyclerView and CardView widgets for all

RecyclerView and CardView tutorial icon

Android’s latest release, Lollipop (Android 5.0 API Level 21) includes the new RecyclerView and CardView widgets. They’re also made available for use on devices running API Level 7 and above through the Support Libraries.

The RecyclerView provides a more advanced and flexible way of displaying lists than the old ListView.

The CardView widget enables you to display views inside a card. You can design the card so that its look is consistent across your app.

Using Toolbars in your apps

Toolbars

Android toolbar icon

A Toolbar is similar to an ActionBar.

It’s a ViewGroup so you can place it anywhere in your layout. You can even replace the ActionBar with a Toolbar.

Toolbar’s are also more flexible. You can modify its size, colour, position, etc. You can also add logos, labels, navigation icons and other views to it.

With the release of Android 5.0 and material design, Android has updated the AppCompat support libraries so that we can use Toolbars on devices running API Level 7 and up.