Monday, March 3, 2014

10 Things To Do With Your New Moto G

I got my Moto G recently and after using it for few days I thought of sharing my experience and few of the things that I did with my new device to boost the overall experience.

Below is a list of 10 things you can do with your brand new Moto G. Although this is not an exhaustive list but it will help you get started with getting the most out of it.

1. Data Migration: You must have done this already but just in case if you haven't, then migrate data from your old phone to your new Moto G using Motorola Migrate. Simply open Motorola Migrate in your Moto G and it will guide you further. The data transfer happens in a very smooth and seamless manner. You can also check out the "Assist" and "Care" apps, again these are the inbuilt apps provided by Motorola.

2. KitKat Upgrade: Upgrade your phone's OS to the latest version KitKat 4.4.x. Read more about KitKat on Android's developer portal later. But till then rest assured that you will be getting the best of the Android experience after using KitKat.

3. Hidden Goodies: You must have seen the KitKat logo appearing on Moto G or Nexus 5. And if you are wondering how to get it then simply follow these steps

Open Settings > About Phone > Android Version. The magic begins here. Tap rapidly on Android Version option for 4-5 times. You will see a Big K on the screen.

Now, again tap rapidly on the screen for 4-5 times and voila! You have your Android KitKat screen.

And now, press and hold the screen, you will get a screen with lots of colorful Android icons. You can play around for some time by tapping on them. I will keep that screen a surprise for you :)

4. Improve Battery Performance: Motorola boasts of the fact that the battery of Moto G can last upto 24 hours but for that to happen you will have to set few configuration settings right.
  • Brightness: Set brightness to AUTO and let the device take care of altering the brightness of your screen. And trust me, Moto G does a great job here.
  • Sleep Time: You can set the timer for sleep mode when your phone is inactive. It is advisable to keep it as low as possible.
  • Location Settings: If the location settings are ON on your device then drag down the notification bar, click on the "Location" icon and select the BATTERY SAVING mode. 
  • Live Wallpapers: It is a known fact that live wallpapers consume a lot power than regular wallpapers. So be wise while setting your wallpaper.

5. Activate Developer Options: This is for the geeks and Android enthusiasts who like adventure in their lives, to activate developer options on your device follow these steps
Go to Settings > About Phone > Rapidly tap on the Build Number few times and it will activate the developer options for you.

6. Setup your Motorola Device ID: Setting up Motorola Device ID helps you in tracking your device in case it gets lost. You can also use this ID to get help from Motorola using their Moto Care app. To set it up go to Settings > Motorola Device ID > Select your existing Google account from the drop down.

7. Get Lock Screen Widgets: KitKat provides this feature of setting widgets on your lock screen. You will already see a camera icon on the bottom right of your lock screen. Simply swipe right to left to open your camera. But apart from this you can add new widgets on your lock screen. Enable it by going to Settings > Security > Check enable widgets option. Once you have done that on your lock screen swipe left to right. You will see a new screen where you can add widgets. You can add such screens as many as you want. Remove them by pressing and holding for couple of seconds.

8. Install few useful utility apps: Although Moto G has great exteriors in terms of the build quality and ergonomics I am a little skeptical about the power button. It remains slightly loose in its socket which feels a little flimsy. So the very first app that I installed on my device was "Screen Off and Lock" app. There are a lot of other similar apps in the store but I personally found this useful since it provides a shortcut to turn off the screen and lock the phone in the notifications bar itself. So you can practically lock your phone from anywhere. The reason I am suggesting such apps is that it will reduce the use of the power button significantly. The little you use it, the longer it will last.

For cache cleanup and memory boosting you can try "Clean Master" app. Pretty good!

9. Redeem Free Drive space: Google is providing 50GB of free drive space for 2 years with your Moto G. To redeem that just open the Drive app and you will see a button to Redeem your free space. Click on it and that's it! I checked with a Motorola customer care executive regarding the strategy of Google after 2 years. How much that 50GB will cost us? But he didnt have any answer to it as of now. As per him, Google will intimate everyone about their plans later.

10. Google Now: Lastly, one of my most favorite apps from Google. I would suggest you to get the most out of this fabulous app. Store your home location, your work location, your favorite team. Google will keep giving you updates and share news articles in the form of cards. Unfortunately the command "OK Google" doesnt work on Moto G but you can still go ahead and try the voice search and ask random questions to Google. You will find few useful commands over here - Google Voice commands. I think they have not mentioned this but you can use "Navigate to destination" command to open Google Navigate and set destination in one go. Saves a lot of time and effort. Big THUMBS UP!!

So like I said in the beginning this is not just about it. You guys can explore yourself some of the cool stuff about Moto G as well as Android KitKat and let me also know about it by posting them here. Cheers!

Saturday, July 6, 2013

Solution: Sony Vaio battery plugged in but not charging

Few days ago I found that although my Sony Vaio laptop was plugged in to the charging source the battery was actually not getting charged at all. I left the laptop on charging mode for almost two straight days but the battery charge didn't move up even by 1%.

Sony Vaio battery not charging
This was very frustrating since the Vaio Control Care tool showed that the charging performance of my battery is still "Good".

I, frantically, searched all over the internet for the solution and found that quite a few people have faced this problem and there are multiple solutions to solving this, which may vary from case to case.

Finally I found this one solution which worked in my case! Try it
  1. Put the laptop on charging mode.
  2. Shut down your laptop.
  3. Remove the battery and restart it.
  4. Now uninstall the Microsoft ACPI-Compliant Control Method Battery driver. For this go to Device Manager >> Batteries >> Microsoft ACPI-Compliant Control Method Battery >> right-click Uninstall.
  5. Once this is done, shut down your laptop again.
  6. Now install the battery back into it and restart.
  7. That's it. Now your laptop should be getting charged.
Tip: You can set the amount of battery to be charged using the Vaio Control Care. To do this open the Vaio Control Care software and go to Battery (inside Power Management) >> Advanced Settings. Lower the percentage higher the battery life but lower the amount of standby time on battery mode, which is self-explanatory I guess.

Hope this helps you.

Tuesday, July 2, 2013

Struts2: How to display data contained in a list/map/List of Object from Java to screen

Today we will learn how to pass data stored in List or Map from Java classes to screens (JSP in this case) using Struts2
Display list/map data from java
using Struts2

Pre-requisite: You need to include the struts tag libaries in your web project and put the below line in your JSP to use the tags.
 <%@ taglib prefix="s" uri="/struts-tags"%>

Let's start with a list of string objects.

1. Suppose in your action class (Java) you have a list of String objects which you want to display on the screen.
For eg. List of Movies:
  • Batman Begins
  • The Dark Knight
  • The Dark Knight Rises
  • Inception
  • Memento
  • The Prestige
Yeah you get it! Like millions I am also a Nolan fan.
Now to display this list on the screen you need to create a List object in your action.

 private List movieList;

Now create the required getter/setter methods for this object as below.
Tip: For eclipse users, short-cut to creating getters/setters is ALT+SHIFT+S + R

public List getMovieList() {
  return movieList;
public void setMovieList(List movieList) {
  movieList.add("Batman Begins");
  movieList.add("The Dark Knight");
  movieList.add("The Dark Knight Rises");
  movieList.add("The Prestige");  
  this.movieList = movieList;

As you can see I have added the movies to the movieList object.
Now coming to the JSP, you will have to use the "iterator" tag of the struts library to iterate through the object.

 <s:iterator value="movieList"> //value field contains the name of the object in Java.  
 <div movie="<s:property>"><s:property /></div> //<s:property /> will get the movie names as there is only single value fields in the list  

That's pretty much it. You will get the movie names on your screen.

2. Now let's consider you have a Map and you want to use data from your map object on the screen.

First we will create a Map object just like we did for the list object.

 private Map<String, String> movieMap;  

And the getters/setters

 public Map<String, String> getMovieMap() {  
      return movieMap;  
 // I have created a movie:year of release(key:value) map  
 public void setMovieMap(Map<String, String> movieMap) {  
      movieMap.put("Batman Begins", "2005");  
      movieMap.put("The Dark Knight", "2008");  
      movieMap.put("The Dark Knight Rises", "2012");  
      movieMap.put("Inception", "2010");  
      movieMap.put("Memento", "2000");  
      movieMap.put("The Prestige", "2006");  
      this.movieMap = movieMap;  

Now in your JSP, let's suppose you want to create a node/div which will display the movie name and an attribute field storing the year of release. You need to do something like this.

 <s:iterator value="movieMap">  
 <div year="<s:property value="value">"><s:property value="key" /></div>  

And lastly what if you have a List of Java objects and you need to extract data from those Java objects?
Let's suppose you have a Movie class as below:

 public class Movie {  
      private String name;  
      private int year;  
      private String director;  
      private String genre;  
      public String getName() {  
           return name;  
      public void setName(String name) {  
  = name;  
      public int getYear() {  
           return year;  
      public void setYear(int year) {  
           this.year = year;  
      public String getDirector() {  
           return director;  
      public void setDirector(String director) {  
           this.director = director;  
      public String getGenre() {  
           return genre;  
      public void setGenre(String genre) {  
           this.genre = genre;  

And you create a list of this Movie objects in your action class

 Movie movie = new Movie();  
 movie.setName("The Dark Knight");  
 // similarly you create objects for other movies  
 List<Movie> movieList = new ArrayList<Movie>();  
 movieList.add(/*all the above movie objects*/);  

In the JSP, you need to do two things.
  1. Iterate over the list
  2. Use a local variable to extract the individual properties from the java object
 <s:iterator value="movieList" var="eachMovie"> //here eachMovie is a local variable
 <div year="<s:property value="#eachMovie.year">" //attribute year created with the correspoding value  
       director="<s:property value="#eachMovie.director">" //similarly director and genre are created  
       genre="<s:property value="#eachMovie.genre">">  
 <s:property value=""></div> // name of the movie display on screen.  

That's it! That's how you bind your java objects with your JSP using struts and access the data.
Please post your comments and views on this tutorial.

Sunday, June 23, 2013

ExtJs: How to filter data of a store in extjs: A small and useful tutorial

Damn I hate these English summers. It's not summer if it's gonna rain every now and then!
It's disappointing to see a final of a tournament getting washed out and that too when India was looking so invincible. Sigh! (This was when I thought there won't be a match today).

India wins Champions Trophy
India wins Champions Trophy 2013
But guess what, rain stopped and there was a 20 overs match eventually. And India came out victorious in an absolutely spectacular fashion. Great to see them finally lift the cup. They totally deserved it.

Anyways, today I will show you how to set filters on the data of a combobox (or rather any component having a store).
We shall first start with creating simple store containing data for a combobox: 

// The data store containing the list of cars  
 var cars = Ext.create('', {  
   autoLoad: true,  
   fields: ['key', 'name'],  
   data: [{  
     "key": "Benz",  
       "name": "Mercedes-Benz"  
   }, {  
     "key": "Audi",  
       "name": "Audi"  
   }, {  
     "key": "Ferrari",  
       "name": "Ferrari"  
   }, {  
     "key": "Prius",  
       "name": "Prius"  
   }, {  
     "key": "Lamborghini",  
       "name": "Lamborghini"  
   }, {  
     "key": "BMW",  
       "name": "BMW"  

Now I will create a combobox and assign the above created store to it.
Note: Here I am creating a toolbar and adding the combobox into it. We will need the filter elements along with the combobox further.

Ext.create('Ext.toolbar.Toolbar', {
    renderTo: document.body,
    items: [{
        xtype: 'combobox',
        fieldLabel: 'Choose Car',
        labelWidth: 70,
        store: cars,
        queryMode: 'local',
        displayField: 'name',
        valueField: 'key'

So now you have a combobox displaying all the cars that we have added to the store.
Now let's say we want to add a filter on this data. 
We want two radio buttons, one for BMW and other for Benz. 
If a user selects BMW then only BMW car should be available for selection in the combobox.
And similarly, if he selects Benz then only Mercedes-Benz should be available.
So for this we will first add two radio buttons to our existing toolbar.

 Ext.create('Ext.toolbar.Toolbar', {
    renderTo: document.body,
    items: [{
        xtype: 'combobox',
        fieldLabel: 'Choose Car',
        labelWidth: 70,
        store: cars,
        queryMode: 'local',
        displayField: 'name',
        valueField: 'key'
    }, {
        xtype: 'fieldcontainer',
        fieldLabel: 'Filter',
        defaultType: 'radiofield',
        labelWidth: 40,
        layout: 'hbox',
        items: [{
            boxLabel: 'Benz',
            name: 'size',
            id: 'radio1'
        }, {
            boxLabel: 'BMW',
            name: 'size',
            id: 'radio2'

Now you have your two radio buttons. But they are not filtering the data as we wanted.
To do that we have to handle the filtering in the radiobutton's change event.

 listeners: {
    change: function (radio2, newvalue, oldvalue) {
 //if the newvalue is true that means the radio button is selected
 if (newvalue) {
  // first clear all the existing filters
  // apply filter to the store. Field on which we are filtering is "key"
  cars.filter('key', 'Benz');

We just need to add a similar listener to the other radio button as well. 
Everything remains same except for the filter value

cars.filter('key', 'BMW');

What if you need multiple filters like say you want to see both Benz as well as BMW in the dropdown.
Add another radio button which will filter on both Benz and BMW.

 boxLabel: 'Both',
 name: 'size',
 id: 'radio3',
 listeners: {
  change: function (radio3, newvalue, oldvalue) {
            if (newvalue) {
    // first clear all existing filters
    // use filterBy() to create a customized filter
    cars.filterBy(function (record) {
     // if the key matches either Benz or BMW then return that record
     if (record.get('key') == 'Benz' || record.get('key') == 'BMW') return record;

And lastly you will want to clear all your filters and get the original set of records back.
This is easy and if you have noticed it is something which we have already been doing.

 boxLabel: 'None',
        name: 'size',
 id: 'radio4',
        listeners: {
  change: function (radio4, newvalue, oldvalue) {
   if (newvalue) {
    // clear all filters.

There you go.
Now you can apply filter to all your stores

JSFiddle Demo

Hope you guys find this useful.
Please leave your comments and suggestions here.

Tuesday, June 18, 2013

ExtJs: ext-all-debug.js vs ext-all-dev.js; An advice for beginners

Use ext-all-dev.js for development
ExtJS for Beginners
Use ext-all-dev.js for development
If you go through the Getting Started page of Sencha ExtJs4.1 you will find that in their 2.3 Library Inclusion methods section they have mentioned the following:

When you unzip the Ext JS 4 download, you will see the following files:

ext-debug.js - This file is only for use during development. It provides the minimum number of core Ext JS classes needed to get up and running. Any additional classes should be dynamically loaded as separate files as demonstrated above.
ext.js - same as ext-debug.js but minified for use in production. Meant to be used in combination with your application's app-all.js file. (see section 3)
ext-all-debug.js - This file contains the entire Ext JS library. This can be helpful for shortening your initial learning curve, however ext-debug.js is preferred in most cases for actual application development.
ext-all.js - This is a minified version of ext-all-debug.js that can be used in production environments, however, it is not recommended since most applications will not make use of all the classes that it contains. Instead it is recommended that you create a custom build for your production environment as described in section 3.

So till now I was using the ext-all-debug.js file in my project while development and ext-all.js in the production environment.Quite straight forward right? I thought so too.

But today I found out that there is one more file in the same package which the Sencha team has not talked about at all! I, based on my today's experience, would recommend all of you reading this to use ext-all-dev.js file while doing your development. I repeat, only development!

Just to give you an example.
I had a button on my page to which I had assigned my own id (note: ideally you shouldn't do that).
When I was using the ext-all-debug.js  file, I got no errors at all and the application was working perfectly fine. But after I switched to ext-all-dev.js file, I got the following error on my console:

Uncaught Ext.AbstractManager.register(): Registering duplicate id "ApplyBtn" with this manager

I found out that the Id that I had assigned was not used anywhere in the file (usually we use the id to get handle to the component by doing Ext.getCmp(id)). It was just an unnecessary config property. 
I am not saying that it was in any way affecting my application but still it was not required. And this is just one of the several small issues that I encountered and corrected. 
Plus, There were few warning messages which suggested me to include some of the JS files in the Ext.require() section.

To sum it up, ext-all-dev.js will really help you in finding out the bugs and lapses in your code. It gives you very clear and precise error as well as warning messages in your browser's developer tool. This way you can correct your mistakes, improve the code of your application and eventually learn coding in ExtJs. Makes me wonder why the Sencha team didn't endorse this file for the novice developers.

Word of caution: Don't forget to switch to ext-all.js in the production. Size of Ext-all-dev.js file is more than 4MB!!