Android for Adhyapak

Welcome to Android for Adhyapak, a newsletter for faculty in India who are teaching the Android Developer Fundamentals course, and students who are learning how to develop Android apps.

We will focus on the Android Developer Fundamentals course, Advanced Android Development course, faculty and student achievements, Google Developers Training events in India, and questions about Android app development.

If you want us to consider including your students' achievements or suggest topics, please use the Android for Adhyapak form.

June 2018

New lessons added to the Advanced Android Development course!

Architecture Components and Simple media playback are now available as a part of the Advanced Android Development course!

Architecture Components are a set of libraries developed by Google that help you design robust, testable, and maintainable apps.

The new Architecture Components lesson introduces you to Architecture Components and teaches how to add those components to your app. The practical tutorial has step-by-step instructions on how to develop an app that you can use as a template for your future app development. Developing your first app using Architecture components can be a bit overwhelming, but the practical will help you through it.

The Media lesson teaches how to integrate video content into your app using the Android multimedia framework. You can play these video files from your app resources (raw resources) or from the device filesystem, or you can stream the files over the network. The practical tutorial guides you through building an app that lets the user play and control video.

News from Google I/O 2018


Google I/O 2018—Google's annual developer festival—was held from May 8-10 at Shoreline Amphitheatre in Mountain View, California.

All the talks were recorded and posted on YouTube. You can watch the full Google I/O keynote (all one hour and forty-six minutes of it) or view just the highlights at Google I/O Keynote in ten minutes. If you only have four minutes to spare, watch The TL;DR show – What’s new from Google I/O 2018.

Important for Android developers to know is that the next release of Android Studio will include the Navigation Editor for creating navigation paths in your apps. This means you can link from one activity or fragment to another just by dragging a line between the layouts.

To learn more, watch Android Jetpack: manage UI navigation with Navigation Controller (34 minutes). To get started using the Navigation Editor right away, take this excellent codelab, which leads you step by step through using the new Navigation Editor. (To use the codelab, you will need to download the preview release of Android Studio 3.2.)

For news about more features coming in Android Studio, watch What's New in Android (34 minutes), or see the five-minute summary.

More sessions from Google I/O on YouTube:

Faculty Spotlight: Satyanandaram N

Satyanandaram N, Lecturer in the Department of Computer Science at IIIT-RK Valley

We were in touch with Satyanandaram N, Lecturer in the Department of Computer Science and Engineering at IIIT-RK Valley, RGUKT-AP. He and other faculty members from his college have successfully trained around 300 students in Android developer fundamentals and are currently training more than 280 students. He studied many Android concepts on his own and also prepared the Android course curriculum for his college. Satyanandaram uses the “learning-by-doing” methodology for teaching his students, encouraging his students to do their final year projects and third-year mini-projects in Android. Around 70% of the students trained by him were placed in top-notch MNCs.

Satyanandaram has been pursuing Android development right from his college days. He was planning to offer an Android course to his students on his own. As luck would have it, he got an opportunity to enhance his skills when the Google Training team, in collaboration with APSSDC, offered the Android Developer Fundamentals course for the faculty in Andhra Pradesh.

From left: Satyanandaram, Nikita and Jocelyn from the Google Developers Training team at the very first ADF Train the Trainer training conducted by Google at VVIT in Vijayawada in September 2016

Initially, when this course was introduced in their college, students had some issues with the 4 GB RAM systems in their Mobile Application Development Lab. Satyanandaram asked his Head of Department and the IT team to upgrade the RAM in those systems and also to equip them with a good internet connection. Thanks to his efforts and cooperation from the management, students now have 8GB RAM systems with high-speed internet.

Satyanandaram also published two papers in the International Journal of Engineering Research in Computer Science and Engineering:

Prashanth Teja, one of the students who Satyanandaram trained, got a job placement in DataHome—GrupoDG Inc. in Mexico. Although from a rural background, he worked his way up to become an entrepreneur, and he co-funded a career planning startup, CEDURA​, and a logistics based startup in South India. He also leads India’s top coding boot camp, THE HACKING SCHOOL​, in Hyderabad.

Featured app: Save Orphan

The Save Orphan app was developed by a team of students who took the Android Developer Fundamentals course from IIIT-RK Valley, under the guidance of Satyanandaram N, Lecturer in the Department of Computer Science and Engineering at IIIT-RK Valley, RGUKT-AP.

This app was developed as two apps: Save Orphan, for members of the public who want to help, and Orphanage Admin, for orphanages.

Using the Save Orphan app, users can:

      • Create a profile to use the app.
      • View details of orphanages and orphans.
      • Make requests for adoption or admission.
      • Donate money to orphanages in need.

Using the Orphanage Admin app, orphanages can:

      • Register their orphanage.
      • Add and edit details about their orphanage.
      • Add and remove orphans from the list.
      • Get notifications about adoption and admission requests.

The complete database is stored in the cloud.

The plight of orphans and the poor children in India is well known, and yet there is no way for orphanages to communicate directly with the public. The Save Orphan app serves as a good communication channel between the orphanages, communities desiring to help, and the interested authorities. Congratulations to the following team members on developing this app:

      • Syed Salma
      • Mohammad Rafi

Faculty events with the Google Developers Training team in India

Advanced Android Development Training & Design Thinking Workshop

Aligned with the program to train two million developers, the Google Developer Training team hosted the first-ever Advanced Android Development training and Design Thinking workshop at Google Bangalore from April 24-28, 2018.

Computer Science and Information Science faculty from top 26 engineering colleges/universities across 4 states who have been actively teaching the Android Developer Fundamentals course in their colleges were invited for a 3-day session on the Advanced Android Development (AAD) course. This was followed by a 2-day Design Thinking workshop by Stanford University’s Hasso Plattner Institute of Design (d.school).

If you are a faculty, interested in teaching Advanced Android Development to students, see the Google Developers Training website, which has the entire repository of course content including concept references, practical workbooks, and slide decks you can use in the classroom.

Ask Jhansi

Hello, I am Jhansi, a passionate mobile developer. Many of you may already know me as Faculty Support in the Google Developers Training team. After working with Symbian, Windows Mobile, and a few other mobile operating systems, I landed in Android. Well, it seems like I've finally arrived where I belong :)

Today’s question is from Professor Ravindra Jagannath Mandale from Rajarambapu Institute of Technology, Rajaramnagar. Thank you Ravindra for asking this question!

Q: What is the difference between minSdkVersion, maxSdkVersion, targetSdkVersion, and compileSdkVersion ?

We all might have seen these properties in the Gradle file in the android->defaultConfig block. Now, let's see what they mean.

minSdkVersion: This is the minimum API level you are willing to support with your app. Also, the Google Play Store uses this property to prevent a user from installing your app if the user’s phone’s API level is lower than the minSdkVersion. You should always declare this property.

maxSdkVersion: Using this property is no longer recommended. If you do specify the property, the Google Play Store uses it to filter your app. If the API level of the user's phone is higher than maxSdkVersion (starting from API level 6), the app is not visible to the user.

targetSdkVersion:This property should be the latest Android version available. If not set, the default value will be the same as minSdkVersion. This property indicates that you have tested your app using this target version. (So, please make sure that you test it. Your users will thank you!)

Starting in Aug 2018, all new apps that are published in the Google Play Store must target at least Android 8.0 (API level 26).

compileSdkVersion: This is used only by the Gradle build system to compile your app with this version of the Android SDK. Changing this value does not change runtime behavior. It is strongly recommended that you always compile with the latest SDK.

Putting it all together, the relationship would look like this:

minSdkVersion (lowest SDK possible) <= targetSdkVersion == compileSdkVersion (latest SDK)

What questions would you like to ask me about Android development? Let me know by filling out the Android for Adhyapak form.

Let's build an app: Spring animation

Today we will build an app using spring animation in Android, which is explained in the Animations lesson in the Advanced Android Development course.

Why do we need animations? Well, to put it simply, animation gives our app the WOW factor! This in turn helps our app stand out in the crowd (considering the fact that there are a ton of apps already in the Google Play Store), which may also eventually help increase the user base. I personally feel that animations not only change the look and feel of an app, but also help the user to navigate the app with ease.

Android includes different types of animations depending on what type of animation you want. Let’s discuss a few of them today.

Drawable animation : Drawable animation lets you load a series of Drawable resources one after another to create an animation, like a roll of film.

Physics-based animation : Physics-based animation creates a natural-looking continuous motion. The key is to use a physics force to govern the movement of the animation, instead of the movement being driven by fixed durations and changes in animation values. And the animation comes to rest when the force reaches equilibrium.

On the left you can see a non-physics-based animation, and on the right a physics-based animation. Notice the velocity of the animated circle decreasing in the case of a physics-based animation.

Non-physics-based animation

Physics-based animation

These two physics-based animations are often used:

  • Fling-based animation is very similar to when you fling (throw) an object in the real world. Initially the object travels with some movement, then gradually slows down and comes to rest, due to friction.
  • Spring animation lets you create an animation, as if your view is attached to a spring. It gives the same bouncing effect you see in the real world when an object attached to a spring is pulled and released.

Coding time:

Today we will be creating an app which animates the launcher icon from right to left using spring animation.

1. Create a new Java project in Android Studio with minimum SDK of API 16, using the Empty Activity template. Set the Application name to “Spring Animation”.

2. Add the support library to the dependencies section of app-level build.gradle file.

build.gradle (Module: app)

dependencies {
    ...
    implementation "com.android.support:support-dynamic-animation:27.1.1"
}

3. Change the “Hello World” Textview to the ImageView below, which we will be animating today. For simplicity, I am re-using the launcher icon, but feel free to add your own images or icons.

activity_main.xml

<ImageView
  android:id="@+id/android_image"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:src="@mipmap/ic_launcher_round"
  app:layout_constraintBottom_toBottomOf="parent"
  app:layout_constraintLeft_toLeftOf="parent"
  app:layout_constraintRight_toRightOf="parent"
  app:layout_constraintTop_toTopOf="parent" />

In MainActivity.java, inside the onCreate() method:

1. Initialize the ImageView.

MainActivity.java

ImageView androidImage = findViewById(R.id.android_image);

2. Create a SpringAnimation object providing the view to be animated (androidImage) and the property to be animated. The property we are animating today is TRANSLATION_X, because we will bounce our ImageView along the x-axis (from right to left).

MainActivity.java

final SpringAnimation springAnimationX = new SpringAnimation(androidImage,DynamicAnimation.TRANSLATION_X, 0);

3. Create a SpringForce object with 0 as the final resting position of the spring so that the view will bounce back to the starting point. Also set the stiffness and damping ratio of the spring.

MainActivity.java

SpringForce springForceX = new SpringForce(0);
springForceX.setStiffness(SpringForce.STIFFNESS_MEDIUM);
springForceX.setDampingRatio(SpringForce.DAMPING_RATIO_HIGH_BOUNCY);

Stiffness, is the strength of the spring, for example if we use STIFFNESS_HIGH the view comes back to the initial position very quickly.

Damping ratio, indicates how rapidly you want the oscillations (the bouncing) to decrease. If you set damping ratio to 0, the view will bounce forever.

4. Set the SpringForce and some initial velocity of the SpringAnimation.

MainActivity.java

springAnimationX.setSpring(springForceX);
springAnimationX.setStartVelocity(1000);

5. Create a click listener for the ImageView. Set the starting value and start the animation.

MainActivity.java

androidImage.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              springAnimationX.setStartValue(300);
              springAnimationX.start();
          }
      });

That’s it! Run your app and tap Android image to see the spring animation come to life…


Try experimenting with a different property like TRANSLATION_Y. You can use more than one animation at the same time. Also try giving a negative start value.

If you want to learn more about animations, or if you are interested in creating a sample app, see Creating property animations practical in the Advanced Android Development course.

Gupshup with Google Developers Training

If you want to tell us about your students' achievements, suggest a topic for this newsletter, or ask a question about Android development, use the Android for Adhyapak form.

Adios… till we meet again.