GPS on Android Wear Devices

With the latest release of Android Wear, wearables with built-in GPS like the Sony smartwatch 3 can now give you a GPS location update directly from the wearable, without a paired phone nearby. You can now build an app like my tracks that lets a user track their run even when they leave their phone at home. For wearable devices that do not have built-in GPS, a software solution has always existed in Google Play Services that automatically uses the GPS from your connected phone.

The Golfshot wearable app uses built-in GPS to calculate your distance to the next hole, even when you don’t have your phone with you.

Implementing GPS location updates

Implementing GPS location updates for Android Wear is simple. On the wearable, use the FusedLocationProviderApi from Google Play services to request location updates. This is the same API that has been available on mobile, so you can easily reuse your existing code and samples.

FusedLocationProviderApi automatically makes the most power-efficient decision about where to get location updates. If the phone is connected to the wearable, it uses the GPS on the phone and sends the updates to the wearable. If the phone is not connected to the wearable and the wearable has a built-in GPS, then it uses the wearable’s GPS.

One case you’ll need to handle is if the phone is not connected to the wearable and the wearable does not have built-in GPS. You will need to delete this and provide a graceful recovery mechanism, such as a message telling the user to bring their phone with them. However, for the most part, deciding which GPS to use, and sending the position from the phone to the wearable, is handled automatically. You do not need to deal with the low-level implementation details yourself.

Data synchronization

When writing an app that runs on the wearable, you will eventually want to synchronize the data it collects with the paired phone. When the wearable is being taken out for a run, especially with the built-in GPS, there may not be a phone present. So you will want to store your location data using the Data Layer API, and when the phone reconnects with the wearable later, the data will be automatically synchronized.


8 websites offering free online coursesPosted

free online courses - Logo

When I started this blog, the very first post I wrote was about websites where you can learn computer programming for free. I believe in the concept of free education for everyone. And recently, many websites/universities have started offering their courses to the world for no cost! So here am listing down 10 such resources where you can learn what you want, for free!

1. Coursera

free online courses - Coursera

This is one of the largest website databases for University open course ware. These courses are at a set time (usually lasting for 10-14 weeks). The main USP of this website is the huge number of courses they are offering. On the date of writing this article, coursera was offering 453 courses, from 88 universities, with the number of subscribers reaching more than 4.9 million!

2. Udacity

free online courses - Udacity

Udacity is a digital university that specializes in computer science courses. Navigation of the website is extremely user-friendly. Each course is arranged in video lectures – each of approx. 5 mins each – which are free of cost! In addition to the class, Udacity offers an online forum where students can collaborate together, study, and work in groups.

3. Udemy

free online courses - Udemy

Udemy is an online institution that offers courses taught by leading experts. It has both free and paid courses. So you will have to carefully check the cost of the courses you need to take. Udemy also allows everyday experts to create their own class, so you will have to be selective about the courses you want to take as anyone can create a course.

4. Khan Academy

free online courses - Khan Academy

Khan Academy has a variety of video lessons for free. The course subjects are broken down into particular lessons, which is great for students who are looking to learn one principle without taking an entire course. If you prefer reading to watching, this site may not be for you as the lessons are all video based.

5. MIT Open Courseware

free online courses - MIT Open Course Ware

For those looking for courses that will test even the brightest student, MIT is sure not to disappoint. You can download all the course material, which is nearly identical to the course taught at MIT (it even gives you the year and semester it was taught). Being an on-demand course, you don’t have any ability to connect with others who are taking it. It is simply an independent study for you to study on your own.

6. Open Yale Courses

free online courses - Open Yale Courses

Open Yale courses offers a great website that is easy to navigate and comprehensive. There are a variety of subjects offered, which can either be downloaded as a zip file, or viewed online. Each lecture has a video (which was recorded during the actual course on campus), plus a transcript and a PDF of slides used during the presentation. There is no need to sign up or create an ID. Yale has made it easy to take their courses.

7. edX

free online courses - edX

edX offers an array of courses from different universities. The classes are of specific length and duration. You can register for classes offered by Harvard, MIT, Berkeley, and other prestigious schools. You will first need to setup an edX account to access the courses. But if you are looking for a class you can do on your own time, this isn’t the website for you.

8. OpenCulture

free online courses - OpenCulture

OpenCulture has compiled a list of University free courses. In their list, they identify what form the lecture comes in (iTunes, Web video, YouTube, etc.). In addition to course listings, they also offer lists of free audio books, free textbooks, and free language lessons. This site does not offer its own curriculum, but rather it compiles resources for easy navigating.

Have you done a course from any other website for free? Do let us know in the comments!

Android One >> Android L >> Android Wear >> Android Assembly

Knowledge is a game changer. I’ve long been inspired by the Internet and how it opens the doors to opportunity. It provides access to knowledge, no matter who you are or where you are. For instance, it doesn’t matter if you’re a Nobel Laureate at a world-class research center or a young student at a rural school in India, with Google Search, you have the same information at your fingertips as anyone else.

If we look at how people are getting online and accessing information today, increasingly it’s through a smartphone. While 1.75 billion people around the world already have a smartphone, the vast majority of the world’s population—over five billion more—do not. That means most people are only able to make simple voice calls, rather than connect with family through a live video chat, use mapping apps to find the closest hospital, or simply search the web. We want to bring these experiences to more people.

Creating and Storing Log File on device in Android

Hello Friends,

        Today, I am sharing another android tutorial which helps you in Creating
and Storing Log File in your android phone.


package com.example.logfileimplementation;


import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends Activity {

public static final String SDCARD = String.valueOf(Environment
TextView mTextView;
protected void onCreate(Bundle savedInstanceState) {
try {
mTextView = (TextView) findViewById(;
mTextView.setText(“Android crash Reporter”);
} catch(Exception ex) {

public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(, menu);
return true;

// Creating App Directory For Log File
private void createAppDirectories() {
File dir1 = new File(Utilities.APP_DIR);
if (!dir1.exists()) {

// Deleting App Directory which is used for Log File
private void deleteLog() {

File log = new File(Utilities.LOG_FILE_PATH);
if (log.exists()) {


package com.example.logfileimplementation;  
public class Utilities {  
 public static String APP_DIR = MainActivity.SDCARD+”/Logfile”;  
 public static String LOG_FILE_PATH = APP_DIR+”/ myapp_log.txt”;    
 public static void writeIntoLog(String data)   
  FileWriter fw = null;      
  try {  
   fw = new FileWriter(LOG_FILE_PATH , true);  
   BufferedWriter buffer = new BufferedWriter(fw);     
  } catch (Exception e) {   

3. activity_main.xml 

<RelativeLayout xmlns:android=””  
    tools:context=”.MainActivity” >  
        android:text=”@string/hello_world” />  
4. AndroidManifest.xml 

<?xml version=”1.0″ encoding=”utf-8″?>  
<manifest xmlns:android=””  
    android:versionName=”1.0″ >  
        android:targetSdkVersion=”18″ />  
    <uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE”/>  
        android:theme=”@style/AppTheme” >  
            android:label=”@string/app_name” >  
                <action android:name=”android.intent.action.MAIN” />  
                <category android:name=”android.intent.category.LAUNCHER” />  
Hope this will help you.

Enjoy Coding. Cheers…. 🙂

Amit Badgujar

A Productive Android Development Environment

In the past 6 months, my Android development environment has changed quite a lot. If you follow me on Google+ and/or Twitter, you may have noticed these changes reading some of my latest tips. I love talking about UI and performance but I also seriously consider tools are crucial entities in the process of developing nice and polished Android apps. In this post, I share about my experience and the tools I use everyday when coding:

  • A blazingly fast virtual device: Genymotion
  • A powerful IDE: Android Studio
  • An evolved build system: Gradle

Developing awesome apps requires energy, passion and commitment. But I also believe great applications come from great development environment. Indeed, I have always thought applications are images of the tools developers are using. Fast emulator involves faster testing which, in turn, involves more polished applications. In the same way, intuitive and user-friendly development tools initiate/inculcate developers with a sense of UI/UX design they can reflect in their products.

Put simply, I am convinced the quality of the dev tools we are using are a direct consequence of the quality of the apps we are creating (and vice-versa). I have always been disappointed about how rustic and raw concrete Android dev tools were but it appears Google is now making a clear turn towards polished and productive dev tools. In addition to that, I am thrilled to see some companies such as Genymobile help the entire ecosystem to move in this direction.


The name of Genymotion is probably completely unknown to you. But I assure you this won’t be the case for so long. You will quickly learn to remember its name once you will try it out. In a nutshell, Genymotion is a feature-complete replacement for the default Android emulator (which has became un-usable due to its serious lack of performance with the latest versions of Android) that can be downloaded on the Genymotion website. The solution is based on Virtual Box and hence consists on virtualizing an Android device rather than emulating it.

"Genymotion logo"

I don’t consider myself as a virtualization/emulation expert but it looks like emulation is not an option anymore. As of today, the iOS SDK offers a simulator (apps are compiled to target the host architecture) and the latest Windows Phone SDK is bundled with a Windows Phone Emulator which is actually a virtual machine. I have the feeling virtualization is the best solution to solve both the performance issues inherent to emulators and the “binaries differences” simulators suffer from.

If you have already tried Genymotion, you already know the key difference between the default emulator, an hardware device and Genymotion: speed! Genymotion is extremely fast and makes Android development a pleasure. Genymotion relieves you from the burden of switching from your work station to your hardware device for testing. Thanks to this amazing piece of software, everything happens on your own work station.

In order to demonstrate how speedy Genymotion is, I ran a small project of mine with a few instrumentation tests on both my hardware device (a Nexus 4) and an instance of Genymotion running on my MacBook Pro. The outputs are just self-explanatory, running the instrumentation tests on Genymotion is at least 10 times faster than on a Nexus 4:

"Tests comparison"

I first tried Genymotion when it was still known under the name of AndroVM. At that time, the product was clearly a tool with a great potential. But its lack of polish and its hard setup was making it a no-go in most Android development environments. The latest version of the software clearly demonstrates Genymobile (the company behind Genymotion) decided to push Genymotion to the next level.

After a nice new demo by the Genymotion team at Droidcon France, I gave it another try and after a single hour playing with it and testing it, I decided to start using it everyday when developing. Thanks to Genymotion, my personal hardware device is now almost only necessary for real-life/final development phase testing.

Speed is one of the most important aspect of Genymotion. However, it also offers some other nice features:

  • Tested & trusted ROMs: The team is working hard on ensuring Genymotion ROMs are CTS-compliant. They recently announced Genymotion already passes 99.4% of the AOSP CTS. We can expect the ROMs to be fully compliant with the CTS soon.
  • Hardware management: You can already emulate a lot of things in a very cool way. One of my favorite option is the GPS sensor management. You only need to move a marker on a map and Genymotion forwards the appropriate GPS fix. This is insanely handy when developing location-based apps.

GPS control center

  • Google Play Services support: Some ROMs being bundled with the Google apps, you have access to the exact same features a real device has. Thus, you can install and test frameworks such as Google Play Services. This lets you test your apps even if they are using Google Maps Android API v2 or the latest location APIs (fused location provider).
  • Full integration with Android Studio & Eclipse: Genymotion presents a simple UI to start/create new virtual devices in a blink of an eye. If you are not fond of this small piece of software you can alternatively use the Eclipse or the Android Studio / IntelliJplugins.
  • Platform independent: Just like you can develop Android application on Windows, Mac OS X or Linux, Genymotion comes with several flavors: one for each platform/architecture.
  • Shell-capable: Genymotion provides a tiny shell enabling you to script some modifications of sensor states.

Let’s be clear, having a fast virtual device doesn’t mean you don’t have to test on real device. It is a good opportunity to prototype and polish your applications in a fast manner. However, real devices are still the best way to ensure everything runs smoothly in real life.

Genymotion still suffers from some minor bugs/missing features and from what I consider a disappointing UI1 (it’s still a beta after all). But its amazing fastness, true potential and ease of integration to the development environment makes it an obvious choice in your development toolkit. I personally know some of the guys in the Genymotion team and I am confident about the future of the software. They work hard on improving a tool that is probably the biggest step forward in Android emulation/virtualization/simulation since Android has been revealed in 2008.

Android Studio

About 5 years ago, I started developing my first Android app: a school project. At that time, the framework was only available as an early look and I chose Eclipse as my main IDE for two main reasons:

  • Eclipse was the required IDE for computer science classes
  • Eclipse was the only IDE bundled with an Android plugin

About 6 months ago, I switched to IntelliJ and more recently (since Google I/O 2013) to Android Studio. The reason behind the switch is pretty logical. Indeed, Eclipse was starting to be a pain in the ass for most of my projects. It was mainly too slow and was crashing often. After almost 5 years using Eclipse, switching to IntelliJ/Android Studio was not easy but it wasn’t painful either. The learning curve is quite impressive: it only took me an entire week to get used to the new shortcuts, the new look/appearance and some of the main features of the IDE.

In addition to being fast and stable, Android Studio has several advantages over Eclipse you can discover either by downloading and playing with the software or by watching the Google I/O keynote and the “What’s new in Android development tools” session Tor Norbye & Xavier Ducrohet did.

Android Studio

At the time of the writing Android Studio is an “I/O preview” and in version 0.1.6. The version number may not refer to a final version, Android Studio relies on the shoulders of a giant. If you are not fond of Eclipse and are looking for something new, you should definitely give Android Studio a try.

Gradle build system

At Google I/O, I wanted to learn about all the new improvements related to the Android development tools. I obviously attended all of the talks related to the new Gradle-based build system. Even though the Gradle plugin is still in a development phase (0.4.3 at the time of the writing), I already strongly encourage people to use it in their projects.

I recently switched all of my projects to the Gradle plugin. The main reason behind that is the new build system finally deals with all of the features an Android developer may need. Moreover, Android Studio works best with Gradle. Here again, the plugin is not perfect of course but I am sure the Android tools team is working hard on polishing this new build system.

Here are some of the features I appreciate the most:

  • Package renaming: This is particularly useful if you want to have both the debug and release versions (and more?) of your application on the same device at the same time.
  • Powerful dependencies management: While this is clearly not new to Maven users, it is a huge leap forward for developers using the current Ant-based build system.
  • Integration & development similar builds: The new build system has been designed so that the builds executed on the continuous integration server are similar to the ones built by developers on their work stations.
  • Easy and sharable signing configuration: The new plugin shares project signing configurations. This is extremely useful if you want the debug key to be used by all of the developers in your team2.
  • Product flavors: Flavors are particular version of your application that can have a different package name, version name/code, etc. This is mostly useful when you need several APK outputs: a free and a paid APK.

If you want to send feedback, report bugs, ask for help, etc. I encourage you to go to the adt-dev Google group. Chances are high, some people like Xavier Ducrohet (a Google engineer on the Android tools team) will help you (in case you post complete and precise questions of course). Here are some important links that helped me to switch to the new Gradle-based build system:


All of the tools described in this post make the Android development environment more efficient and productive than ever. They all are works in progress but they already demonstrate Android has a bright future ahead of itself. New Google-powered tools such as Android Studio and the new Gradle build system in addition to the insanely powerful Genymobile’s Genymotion are excellent initiatives to future-proof Android development tools.

If you are still thinking about what to do, here is my piece of advice for you. Do not hesitate, stop thinking, revolutionize your Android development environment right now by switching to these new awesome tools and help them to be even better than they already are.

  1. While being understandable and self-explanatory, I seriously think Genymotion’s UI could be way simpler. The product is already awesome from a functional/feature point of view. Reducing friction due to the current ineffective UI would make the product truly revolutionary and ground-breaking.

  2. Some APIs and/or frameworks such as Google Maps Android API v2 require an API key based on the key used to sign the APK. Sharing keys between developers at the project level, may relieve you from the burden of managing several API keys.


ChromeCast Apps

Got Chromecast? Google’s simple $35 streaming stick has been great for basic stuff since the start, but as more diverse third-party apps start to show up for the device, its capabilities are growing even greater.

Some apps have been around for a while — things like Netflix, Pandora, HBO Go, and Hulu Plus, for instance — but there are also some less obvious options you might not have yet noticed. And some of ’em offer pretty interesting possibilities for making your Chromecast do more.

Here are five Chromecast apps for Android that are worth checking out:

1. MyCastScreen

Chromecast’s default home screen — you know, the rotating photographs with a clock in the corner — sure is attractive. But it isn’t terribly functional.

If you want to put a little more punch in your Chromecast display, MyCastScreen might be just the thing for you. The 99-cent app lets you cast cards with the time and date, local weather, local traffic, and current news headlines from a source of your choice onto your TV screen.

Chromecast Apps Android: MyCastScreen

The app is pretty limited in terms of customization at the moment, but its developer promises much more is on the way soon — including additional cards along with options for custom background images and hiding or rearranging cards on the screen.

2. Dayframe

Wish your Chromecast could act as a custom slideshow and cycle through your favorite social media photos? Meet Dayframe. The app connects to a variety of online services — Facebook, Instagram, Twitter, Google+, 500px, and even Dropbox — and mixes up all the content you want to create an ongoing personalized stream.

You can also set Dayframe to show a variety of random images related to specific topics, like space, architecture, or different types of art.

Chromecast Apps Android: Dayframe

The main Dayframe app is free, though it does place a small logo on top of all content on your screen. You’ll need to upgrade to the Prime version in order to get rid of that; the upgrade is done via an in-app purchase and costs three bucks (but is occasionally on sale for 99 cents).

3. AllCast

If you’ve been dying to stream local content from your phone to your TV, AllCast is just the program you’ve been waiting for. The app makes it easy to cast images, videos, and music from your phone’s internal storage to a Chromecast device, giving you a hassle-free way to get your non-cloud-connected material onto the big screen.

The app works with Dropbox and Google Drive, too, in case you ever want to cast specific images or multimedia files from either of those places.

Chromecast Apps Android: AllCast

AllCast is more focused on manual file-by-file casting as opposed to the ongoing slideshow type of thing Dayframe does, but if that’s what you’re looking to do, it’s certainly worth a look.

The main AllCast app is free but limits you to one minute for viewing any particular picture or video. In order to lift that restriction, you’ll have to pony up five bucks for a premium license.

4. Pocket Casts

One of the best podcast apps on Android now works with Chromecast. Get your favorite audio and/or video programs on your TV with the tap of a single button — what more could you want?

5. Binary Clock for Chromecast

This one’s a bit silly but still fun: As its name suggests, the app lets you cast a simple binary clock onto your TV screen. You can customize the color as well.

Chromecast Apps Android: Binary Clock