What is MiTM attack and How it works

When you request a page, the information travels from the server to your computer via a super-highway of cables, routers and computer switches that stretch the Internet across the world. Like highway robbers of old, modern attackers knows you are vulnerable at every “junction.” These spots are where your data can be intercepted, read and even altered.

What is MiTM attack ?

A man-in-the-middle attack is a procedure that allows an attacker to interpose between you and the computer you are communicating with to read the conversation or alter it. The procedure was extremely common before the massive switch to HTTP-Secure, and it is still common nowadays, although a little more complicated to carry out.
After targeting PCs for years, the omnipresent man-in-the-middle attacks have moved on to mobiles. On account of failing to assess the impact of these attacks, consumers connect their phones to public networks to stay connected, especially when on vacation.

The biggest threat arises from the slow detection rate. Users can’t always figure out if the network they are on is legitimate or if some is listening to the traffic, whether at the airport, hotel or coffee place down the street. Our internet addiction has also driven us to use the same device for both business and pleasure, automatically exposing ourselves to risks. End-users are the biggest threat to enterprises; once connected to an unreliable network corporate data, credentials or email could be leaked.

How MiTM attacks work

When two parties start a conversation, they typically establish a connection and exchange what are called public keys – keys used to encrypt conversations before they get sent across the wires. Let’s imagine Alice and Bob chatting on the web. When Alice reaches out to Bob, she sends her public key. Bob will encrypt all the messages for Alice with her public key. Bob in turn would also send Alice his public key. When Alice gets the encrypted message from Bob, she decrypts it with her private key and reads it.

Now imagine a third person between Alice and Bob. His name is Peter. Peter intercepts Alice’s public key as it travels to Bob and substitutes it with his own public key. He also intercepts Bob’s public key and substitutes it with his own as it travels to Alice. Now both Alice and Bob encrypt information with Peter’s public key and Peter can decrypt them with his own private key. After decryption, he reads the message, maybe alters it, then encrypts it with Alice’s public key intercepted in the first step and forwards the message to Alice. He proxies all communication to and from Bob or Alice and neither of them knows he’s listening.

Rogue or unprotected Wi-Fi networks are not the only entry point a hacker can use to launch a man-in-the-middle attack. Each time you go online and use a proxy service to anonymize your IP address or circumvent the restrictions at your workplace, remember that the proxy server normally acts as a man in the middle.

Your page visits and online activity like file transfers, financial transactions or emails can be captured by criminals through a hostile proxy server. You are exposing all your information to third parties.

VPN servers should safeguard your infrastructure by keeping your connection encrypted. Compromised or rogue VPN servers also could allow third parties to steal your data but, even worse, they can reroute your traffic and use your internet connection for illegal schemes. In the absence of a secure connection, by the time you figure out you’ve installed a malicious program or website it could be too late.

How to identify them

If you’re not tech-savvy, there’s not much you can do about this. Man-in-the-middle attacks are very difficult to detect, so prevention is better than cure.

If you’re on vacation and your phone automatically connects to a network, you could fall victim to a MitM attack. If asked to install a VPN app or accept a digital certificate, you’re on your way to a man-in-the-middle attack.  The easiest way t

Top 3 Mobile Game Based on Pokémon Go

As I sit here and watch as millions of people every day download Pokemon Go on their smartphones, it makes me wonder if mobile gaming has evolved form the 2D gaming realm to an augmented reality-enhanced future.

While Pokemon Go is only one game, the implications on the gaming space will be gigantic. Not only will we see an influx of augmented reality-based games which utilize data from the real world. Here are a few predictions I will make for the next 2-3 years based on the extraordinary success of Pokemon Go:


#1 - At Least 2 Augmented Reality Games Will Eclipse the Records Broken By Pokemon Go Over the Next 18 Months

I'm betting that more than a handful of mobile gaming developers are already working on concepts for augmented reality games which follow in the footsteps of Pokemon Go. In fact I'm willing to guess that at least two, maybe as many as 3-4 games, will launch over the next 18 months and actually eclipse the success that Pokemon Go has seen in its early going. These games will likely take Augmented reality to the next level, allowing users to build upon the real world.

#2 - Augmented Reality Games will Drive a Market for Mobile Augmented Reality Headsets

I predict that the sheer excitement of such AR games will push hardware manufacturers to create AR headsets that are compatible with mobile phones much quicker then they may have originally planned to do so. While many manufacturers are developing virtual reality headsets, there may now be a sudden shift towards augmented reality headsets. Using mirrors and special optics, it will be entirely possible to transform a smartphone into an AR device, and it won't be all that expensive either.

#3 - A Minecraft-like Augmented Reality Game Will Be an Immense Success

While Pokemon Go has utilized augmented reality to make mobile gaming fun again, the next step will be to allow gamers to build upon the physical world. Imagine a game like Minecraft in which users can build a castle in their backyard or the end of their street, and then other users can interact with those creations. We will see a game which allows players to build virtual objects on a map of the physical world. We will then be able to explore the mixed reality world created by the entire gaming community as we walk along the street. This is where AR gaming is headed next and I think that within 2 years, perhaps 3, such a game will be here.

The future looks bright for AR gaming and I can;t wait to see what comes next. 

Intersting Story behind the name of Bluetooth

Bluetooth is named after a 10th century Scandinavian King, know the story behind it

The introduction of Bluetooth in technology came as a revolution, which not only improved the utility of mobile phones, but also made sharing of files a pushover. It gave a new meaning to the world of wireless communication. But have you ever pondered how Bluetooth got its name in the first place? Have you ever wondered where the origins of the term “Bluetooth” came from?

However, there is a very interesting story behind this.

In 1996, a number of companies – Intel, Ericsson, Nokia, and later IBM – were looking to standardize the industry around a short-range radio link for doing a number of things. Each company had been developing their own short-range radio technologies, but all the names they came up with sucked. That is when an obscure Scandanavian king came from the Middle Ages.

King Harald Gormsson is famous for ruling Denmark and then Norway between about 940 and about 986. King Harald was also famous for completing his father’s work of unifying the various Danish tribes into one Danish kingdom around 970. Even though, he was only able to maintain this unification for a few years.


Like many medieval rulers, he also had a nickname: Blatonn in Old Norse (a member of the Germanic family of languages) or Blatand in Danish. It means Bluetooth. The exact origin of the nickname is up for debate, but many scholars believe that King Harald was called Bluetooth because he had a conspicuous dead tooth that exactly looked black and blue. It does make sense.


So, what does a turn-of-the-last-millennium Viking king have to do with wireless communication? He was a uniter!

In the mid-1990s, the wireless communication field needed some uniting. Many corporations were developing competing, non-compatible standards. Several people saw this growing division as a weakness to widespread adoption of wireless.

That is when Intel engineer Jim Kardach took on the role of a cross-corporate mediator devoted to getting various companies together to develop an industry-wide standard for low-power, short-range radio connectivity. He was equally supported by Ericsson engineer Sven Mattisson.

While having a conversation on history, Mattisson told Kardach that he had just read a book called The Longships by Frans G. Bengtsson that compiled the travels of Danish warriors under the reign of King Harald “Bluetooth” Gormsson. Later, Kardach read The Vikings by Gwyn Jones that featured the reign of Harald, whom he viewed as an ideal symbol for bringing competing parties together, as he explained:

“Bluetooth was borrowed from the 10th-century, second king of Denmark, King Harald Bluetooth; who was famous for uniting Scandinavia just as we intended to unite the PC and cellular industries with a short-range wireless link.”

“Harald had united Denmark and Christianized the Danes!” Kardach wrote in a column a decade later. “It occurred to me that this would make a good codename for the program.”

All the different interested parties finally came together to form the Bluetooth Special Interest Group, which developed the agreed-upon standard we know and love today. “Bluetooth” was originally meant to be just a code name for the technology. It ultimately ended up sticking though and became the official name of the standard.


The millennium-old story doesn’t end there. The Bluetooth logo also derives from “Harald Blatand”, with the long-branch Nordic runes for “H” and “B” comprising the design you see in the blue oval of the logo. The now iconic Bluetooth logo is in fact a combination—officially known as a bind rune—of King Bluetooth’s initials in Scandinavian runes: ᚼ and ᛒ. When you join the two to make a bind rune and drop it on a blue background, you get the acquainted Bluetooth logo.

So, this is how, we got this name and the symbol! Interesting, isn’t it?

Yahoo acquired by Verizon in $128 billion

After months of speculations, negotiations, and rounds of meetings, finally Yahoo! is sold. According to WSJ, citing person familiar with the matter, Verizon acquires Yahoo! for $4.8 billion.


The board of Yahoo! has also accepted the terms and conditions of the Verizon offer, ending the much-talked auction process for the Internet major that rocked the market once.

VERIZON ACQUIRES YAHOO!: THE DEAL

While the deal might have brought a sign of relief for many, it is a remarkable fall of Yahoo!, which was valued $128 billion once. The exact terms and conditions are yet to be known, though, the deal includes Yahoo’s core internet business along with some real estate. However, the patents are not a part of the deal.

This is the second major acquisition in the tech industry in the last two months. In a sudden move last month Microsoft had acquired LinkedIn. The rumors mills, however, were already buzzing the internet about Verizon-Yahoo! deal for some time.

WHAT WAS YAHOO! PUT UNDER HAMMER

If you are following the topic at least for the last few months on Dazeinfo, then you must know the answer to this billion dollar question. It was none other than Yahoo’s current CEO, Marissa Mayer, failed to turn the tides for Yahoo! and finally bowed to the mounting pressure from stakeholders and the board.

The much-hyped MaVeNs strategy, designed and defined by Marissa Mayer to bring back the golden era of Yahoo! failed measurably. Just a few months back we did a detailed analysis of why and how Marissa Mayer’s MaVeNs strategy became nothing but a disaster for Yahoo!. The ex-Googler joined Yahoo! by replacing its interim CEO, Ross Levinsohn, in July 2012. Under the leadership of Mayer, Yahoo! had shown the signs of gaining its lost ground during the early days of Mayer in control. Soon, Mayer started struggling amid to the reports of having differences on strategies with its senior executives.

For the last few quarters Yahoo! has been bleeding badly, putting Marissa Mayer under immense pressure to control overheads of the company. She was also asked to create a respectable exit route for stakeholders, and of course, for herself as well. In Q2 2016, Yahoo!’s revenue dropped by 20% from a prior year. Even the acquisitions made by Yahoo! in the recent time were not bearing any fruits, the biggest disappointment came in the form of Tumblr, acquired by Yahoo! in 2013. The company had to write down the valuation of Tumblr by nearly 65%, from $1.1 billion, the amount Yahoo! paid to acquired Tumblr.

WHAT’S IN IT FOR VERIZON

Let me say it, Yahoo! is still a beast and it is still worth every penny Verizon Communication is paying to get hold of it. Verizon, the largest telecom & networking company in the US, serves to 145 million internet users and after acquiring Yahoo! the company can easily extend its advertising base by 200 million more visitors. To strengthen its core business and grip the Internet Verizon acquired AOL in 2015. However, amid to the growing competition from Google and Facebook, Verizon has been strengthening its presence in the mobile advertising space. With access to the personal information of millions of users Yahoo! has, control over multiple platforms likes Tumblr, Flickr, and ability to ride on the back of analytics tools like Flurry and BrightRoll, Verizon has a better chance to compete in digital space dominated by two internet giants.

YAHOO! WILL STILL BE LED BY EX-GOOGLER

No, we are not talking about Marissa Mayer, the ex-Googler. And, to be honest, it would be too early to analyze the possible fate of Marissa Mayer under the umbrella of Verizon. But, and interestingly, Yahoo! will be led by another former Googler: Tim Armstrong, who was the CEO of AOL, acquired by Verizon last year. While Marissa Mayer could receive a severance package worth about $57 million, Armstrong is expected to lead the combined Internet companies consisting of AOL and Yahoo! at Verizon. At this time, it looks feasible and makes sense as Armst

Material Design Textfield in Android

Are you bored with simple Android design and want some attractive look for your Android apps. Then you need to tends towards Material design which give you power to design your app easily by their pre-build library.
I am telling you about material design texfield for Android UI which is one of the best library of Material design.



It is a different beautiful Floating Edit Text

How to Use

Surround your EditText by a MaterialTextField
<com.github.florent37.materialtextfield.MaterialTextField
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        app:mtf_image="@drawable/ic_mail_grey600_24dp"
        >

        <EditText
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:hint="Password"
             android:textColor="#333"
             android:textColorHint="#666"
             android:textSize="15sp" />

</com.github.florent37.materialtextfield.MaterialTextField>

Don't forget to precise a drawable to mtf_image

app:mtf_image="@drawable/ic_mail_grey600_24dp"

Available attributes

<com.github.florent37.materialtextfield.MaterialTextField
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    app:mtf_cardCollapsedHeight="4dp"
    app:mtf_image="@drawable/ic_mail_grey600_24dp"
    app:mtf_animationDuration="1000"
    app:mtf_labelColor="@android:color/holo_red_dark"
    app:mtf_openKeyboardOnFocus="true">

Download from here

Use Google Places Autocomplete API in Android Search Dialog

In this article, we are going to develop an android application with a search panel.

The search panel permits users to search various places using Google Places API and shows the result as a marker within the Google Maps android API V2.

Use Google Places Autocomplete API, in Android Search Dialog


We additionally add custom suggestions to search Dialog with Google Places Autocomplete api.

You can check : Google Maps V2 Android Tutorial

Major files used in this application are listed below :

  1. MainActivity.java : This is the only activity that the application contains and search is invoked from this activity using options menu.
  2. searchable.xml : This is the configuration file for search dialog which defines content provider and suggestion properties.
  3. PlaceProvider.java : The content provider for fetching places from Google places autocomplete API.
  4. PlaceJSONParser.java : Parses the result of Google Places Autocomplete API.
  5. PlaceDetailsJSONParser.java : Parses the result of Google Places Details API.

Download Source Code

This application is developed in Eclipse (4.2.1) with ADT plugin (22.0.1) and Android SDK (22.0.1) and tested in real devices with Android versions 2.3.6  ( GingerBread ) and 4.1.2 ( Jelly Bean ).

Screenshot 1

Screenshot 2

Screenshot 3


Screenshot 4



1. Create new Android application project with the given below details


  • Application Name : LocationSearchDialogV2
  • Project Name : LocationSearchDialogV2
  • Package Name : com.blogspot.geekonjava
  • Minimum Required SDK : API 8 : Android 2.2 ( Froyo )
  • Target SDK : API 17 : Android 4.2 ( Jelly Bean )

2. Download and configure Google Play Services Library in Eclipse

Please follow the given below link to setup Google Play Service library in Eclipse.
http://developer.android.com/google/play-services/setup.html

3. Referencing the Google Play Services library in this project

Please follow the given below link to reference the Google Play Service library into this project
http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject

4. Get the API key for Google Maps Android API V2

We need to get an API key from Google to use Google Maps in Android application.
Please follow the given below link to get the API key for Google Maps Android API v2.
https://developers.google.com/maps/documentation/android/start

5. Get the API key for Google Places API

We can create API key for Google Place API by clicking “Create new Browser key”  available at the “API Access” pane of the Google console URL : http://code.google.com/apis/console.

Also ensure that, “Places API” is enabled in the “Services” pane of the Google console.

6. Add Android Support library to this project

By default, Android support library (android-support-v4.jar ) is added to this project by Eclipse IDE to the directory libs. If it is not added, we can do it manually by doing the following steps :

  • Open Project Explorer by Clicking “Window -> Show View -> Project Explorer”
  • Right click this project
  • Then from popup menu, Click “Android Tools -> Add Support Library “

7. Update the file res/values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
 
    <string name="app_name">LocationSearchDialogV2</string>
    <string name="action_search">Search</string>
    <string name="hello_world">Hello world!</string>
    <string name="search_hint">Search Places</string>
    <string name="search_settings">Search Places</string>
 
</resources>

8. Update the layout file res/layout/activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
 
    <fragment
        android:id="@+id/map"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        class="com.google.android.gms.maps.SupportMapFragment" />
 
</RelativeLayout>

9. Update the menu file res/menu/main.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
 
<item
    android:id="@+id/action_search"
    android:orderInCategory="100"
    android:showAsAction="never"
    android:title="@string/action_search"/>
 
</menu>

10. Create the class file src/com/blogspot/geekonjava/PlaceJSONParser.java

package com.blogspot.geekonjava;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
 
public class PlaceJSONParser {
 
    /** Receives a JSONObject and returns a list */
    public List<HashMap<String,String>> parse(JSONObject jObject){
 
        JSONArray jPlaces = null;
        try {
            /** Retrieves all the elements in the 'places' array */
            jPlaces = jObject.getJSONArray("predictions");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        /** Invoking getPlaces with the array of json object
        * where each json object represent a place
        */
        return getPlaces(jPlaces);
    }
 
    private List<HashMap<String, String>> getPlaces(JSONArray jPlaces){
        int placesCount = jPlaces.length();
        List<HashMap<String, String>> placesList = new ArrayList<HashMap<String,String>>();
        HashMap<String, String> place = null;
 
        /** Taking each place, parses and adds to list object */
        for(int i=0; i<placesCount;i++){
            try {
                /** Call getPlace with place JSON object to parse the place */
                place = getPlace((JSONObject)jPlaces.get(i));
                placesList.add(place);
 
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
 
        return placesList;
    }
 
    /** Parsing the Place JSON object */
    private HashMap<String, String> getPlace(JSONObject jPlace){
 
        HashMap<String, String> place = new HashMap<String, String>();
 
        String id="";
        String reference="";
        String description="";
 
        try {
 
            description = jPlace.getString("description");
            id = jPlace.getString("id");
            reference = jPlace.getString("reference");
 
            place.put("description", description);
            place.put("_id",id);
            place.put("reference",reference);
 
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return place;
    }
}

11. Create the class file src/com/blogspot/geekonjava/PlaceDetailsJSONParser.java

package com.blogspot.geekonjava;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
import org.json.JSONException;
import org.json.JSONObject;
 
public class PlaceDetailsJSONParser {
 
    /** Receives a JSONObject and returns a list */
    public List<HashMap<String,String>> parse(JSONObject jObject){
 
        Double lat = Double.valueOf(0);
        Double lng = Double.valueOf(0);
        String formattedAddress = "";
 
        HashMap<String, String> hm = new HashMap<String, String>();
        List<HashMap<String, String>> list = new ArrayList<HashMap<String,String>>();
 
        try {
            lat = (Double)jObject.getJSONObject("result").getJSONObject("geometry").getJSONObject("location").get("lat");
            lng = (Double)jObject.getJSONObject("result").getJSONObject("geometry").getJSONObject("location").get("lng");
            formattedAddress = (String) jObject.getJSONObject("result").get("formatted_address");
 
        } catch (JSONException e) {
            e.printStackTrace();
        }catch(Exception e){
            e.printStackTrace();
        }
 
        hm.put("lat", Double.toString(lat));
        hm.put("lng", Double.toString(lng));
        hm.put("formatted_address",formattedAddress);
 
        list.add(hm);
 
        return list;
    }
}

12. Create the file src/com/blogspot/geekonjava/PlaceProvider.java

package com.blogspot.geekonjava;
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
 
import org.json.JSONException;
import org.json.JSONObject;
 
import android.app.SearchManager;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
import android.util.Log;
 
public class PlaceProvider extends ContentProvider {
 
    public static final String AUTHORITY = "com.blogspot.geekonjava.PlaceProvider";
 
    public static final Uri SEARCH_URI = Uri.parse("content://"+AUTHORITY+"/search");
 
    public static final Uri DETAILS_URI = Uri.parse("content://"+AUTHORITY+"/details");
 
    private static final int SEARCH = 1;
    private static final int SUGGESTIONS = 2;
    private static final int DETAILS = 3;
 
    // Obtain browser key from https://code.google.com/apis/console
    String mKey = "key=YOUR_BROWSER_KEY";
 
    // Defines a set of uris allowed with this content provider
    private static final UriMatcher mUriMatcher = buildUriMatcher();
 
    private static UriMatcher buildUriMatcher() {
 
        UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
 
        // URI for "Go" button
        uriMatcher.addURI(AUTHORITY, "search", SEARCH );
 
        // URI for suggestions in Search Dialog
        uriMatcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY,SUGGESTIONS);
 
        // URI for Details
        uriMatcher.addURI(AUTHORITY, "details",DETAILS);
 
        return uriMatcher;
    }
 
    @Override
    public Cursor query(Uri uri, String[] projection, String selection,
        String[] selectionArgs, String sortOrder) {
        Cursor c = null;
 
        PlaceJSONParser parser = new PlaceJSONParser();
        PlaceDetailsJSONParser detailsParser = new PlaceDetailsJSONParser();
 
        String jsonString = "";
        String jsonPlaceDetails = "";
 
        List<HashMap<String, String>> list = null;
        List<HashMap<String, String>> detailsList = null;
 
        MatrixCursor mCursor = null;
 
        switch(mUriMatcher.match(uri)){
        case SEARCH:
            // Defining a cursor object with columns description, lat and lng
            mCursor = new MatrixCursor(new String[] { "description","lat","lng" });
 
            // Create a parser object to parse places in JSON format
            parser = new PlaceJSONParser();
 
            // Create a parser object to parse place details in JSON format
            detailsParser = new PlaceDetailsJSONParser();
 
            // Get Places from Google Places API
            jsonString = getPlaces(selectionArgs);
            try {
                // Parse the places ( JSON => List )
                list = parser.parse(new JSONObject(jsonString));
 
                // Finding latitude and longitude for each places using Google Places Details API
                for(int i=0;i<list.size();i++){
                    HashMap<String, String> hMap = (HashMap<String, String>) list.get(i);
 
                    detailsParser =new PlaceDetailsJSONParser();
 
                    // Get Place details
                    jsonPlaceDetails = getPlaceDetails(hMap.get("reference"));
 
                    // Parse the details ( JSON => List )
                    detailsList = detailsParser.parse(new JSONObject(jsonPlaceDetails));
 
                    // Creating cursor object with places
                    for(int j=0;j<detailsList.size();j++){
                        HashMap<String, String> hMapDetails = detailsList.get(j);
 
                        // Adding place details to cursor
                        mCursor.addRow(new String[]{ hMap.get("description") , hMapDetails.get("lat") , hMapDetails.get("lng") });
                    }
 
                }
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            c = mCursor;
            break;
 
        case SUGGESTIONS :
 
            // Defining a cursor object with columns id, SUGGEST_COLUMN_TEXT_1, SUGGEST_COLUMN_INTENT_EXTRA_DATA
            mCursor = new MatrixCursor(new String[] { "_id", SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA } );
 
            // Creating a parser object to parse places in JSON format
            parser = new PlaceJSONParser();
 
            // Get Places from Google Places API
            jsonString = getPlaces(selectionArgs);
 
            try {
                // Parse the places ( JSON => List )
                list = parser.parse(new JSONObject(jsonString));
 
                // Creating cursor object with places
                for(int i=0;i<list.size();i++){
                    HashMap<String, String> hMap = (HashMap<String, String>) list.get(i);
 
                    // Adding place details to cursor
                    mCursor.addRow(new String[] { Integer.toString(i), hMap.get("description"), hMap.get("reference") });
                }
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            c = mCursor;
            break;
 
        case DETAILS :
            // Defining a cursor object with columns description, lat and lng
            mCursor = new MatrixCursor(new String[] { "description","lat","lng" });
 
            detailsParser = new PlaceDetailsJSONParser();
            jsonPlaceDetails = getPlaceDetails(selectionArgs[0]);
            try {
                detailsList = detailsParser.parse(new JSONObject(jsonPlaceDetails));
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
 
            for(int j=0;j<detailsList.size();j++){
                HashMap<String, String> hMapDetails = detailsList.get(j);
                mCursor.addRow(new String[]{ hMapDetails.get("formatted_address") , hMapDetails.get("lat") , hMapDetails.get("lng") });
            }
            c = mCursor;
            break;
        }
        return c;
    }
 
    @Override
    public int delete(Uri uri, String selection, String[] selectionArgs) {
        // TODO Auto-generated method stub
        return 0;
    }
 
    @Override
    public String getType(Uri uri) {
        // TODO Auto-generated method stub
        return null;
    }
 
    @Override
    public Uri insert(Uri uri, ContentValues values) {
        // TODO Auto-generated method stub
        return null;
    }
 
    @Override
    public boolean onCreate() {
        // TODO Auto-generated method stub
        return false;
    }
 
    @Override
    public int update(Uri uri, ContentValues values, String selection,
        String[] selectionArgs) {
        // TODO Auto-generated method stub
        return 0;
    }
 
    /** A method to download json data from url */
    private String downloadUrl(String strUrl) throws IOException{
        String data = "";
        InputStream iStream = null;
        HttpURLConnection urlConnection = null;
        try{
            URL url = new URL(strUrl);
 
            // Creating an http connection to communicate with url
            urlConnection = (HttpURLConnection) url.openConnection();
 
            // Connecting to url
            urlConnection.connect();
 
            // Reading data from url
            iStream = urlConnection.getInputStream();
 
            BufferedReader br = new BufferedReader(new InputStreamReader(iStream));
 
            StringBuffer sb = new StringBuffer();
 
            String line = "";
            while( ( line = br.readLine()) != null){
                sb.append(line);
            }
 
            data = sb.toString();
 
            br.close();
 
        }catch(Exception e){
           Log.d("Exception while downloading url", e.toString());
        }finally{
            iStream.close();
            urlConnection.disconnect();
        }
        return data;
    }
 
    private String getPlaceDetailsUrl(String ref){
 
        // reference of place
        String reference = "reference="+ref;
 
        // Sensor enabled
        String sensor = "sensor=false";
 
        // Building the parameters to the web service
        String parameters = reference+"&"+sensor+"&"+mKey;
 
        // Output format
        String output = "json";
 
        // Building the url to the web service
        String url = "https://maps.googleapis.com/maps/api/place/details/"+output+"?"+parameters;
 
        return url;
    }
 
    private String getPlacesUrl(String qry){
 
        try {
            qry = "input=" + URLEncoder.encode(qry, "utf-8");
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }
 
        // Sensor enabled
        String sensor = "sensor=false";
 
        // place type to be searched
        String types = "types=geocode";
 
        // Building the parameters to the web service
        String parameters = qry+"&"+types+"&"+sensor+"&"+mKey;
 
        // Output format
        String output = "json";
        // Building the url to the web service
        String url = "https://maps.googleapis.com/maps/api/place/autocomplete/"+output+"?"+parameters;
        return url;
    }
 
    private String getPlaces(String[] params){
        // For storing data from web service
        String data = "";
        String url = getPlacesUrl(params[0]);
        try{
            // Fetching the data from web service in background
            data = downloadUrl(url);
        }catch(Exception e){
            Log.d("Background Task",e.toString());
        }
        return data;
    }
 
    private String getPlaceDetails(String reference){
        String data = "";
        String url = getPlaceDetailsUrl(reference);
        try {
            data = downloadUrl(url);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return data;
    }
}
Note : Update “YOUR_BROWSER_KEY" on line 39 with the browser key obtained in Step 5.

Latest library : Java Google Trends API

13. Update the class MainActivity in the file src/com/blogspot/geekonjava/MainActivity.java

package com.blogspot.geekonjava;
 
import android.app.SearchManager;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.view.Menu;
import android.view.MenuItem;
 
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
 
public class MainActivity extends FragmentActivity implements LoaderCallbacks<Cursor>{
 
    GoogleMap mGoogleMap;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        SupportMapFragment fragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
        mGoogleMap = fragment.getMap();
 
        handleIntent(getIntent());
 
    }
 
    private void handleIntent(Intent intent){
        if(intent.getAction().equals(Intent.ACTION_SEARCH)){
            doSearch(intent.getStringExtra(SearchManager.QUERY));
        }else if(intent.getAction().equals(Intent.ACTION_VIEW)){
            getPlace(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
        }
    }
 
    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        handleIntent(intent);
    }
 
    private void doSearch(String query){
        Bundle data = new Bundle();
        data.putString("query", query);
        getSupportLoaderManager().restartLoader(0, data, this);
    }
 
    private void getPlace(String query){
        Bundle data = new Bundle();
        data.putString("query", query);
        getSupportLoaderManager().restartLoader(1, data, this);
    }
 
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
 
    @Override
    public boolean onMenuItemSelected(int featureId, MenuItem item) {
        switch(item.getItemId()){
        case R.id.action_search:
            onSearchRequested();
            break;
        }
        return super.onMenuItemSelected(featureId, item);
    }
 
    @Override
    public Loader<Cursor> onCreateLoader(int arg0, Bundle query) {
        CursorLoader cLoader = null;
        if(arg0==0)
            cLoader = new CursorLoader(getBaseContext(), PlaceProvider.SEARCH_URI, null, null, new String[]{ query.getString("query") }, null);
        else if(arg0==1)
            cLoader = new CursorLoader(getBaseContext(), PlaceProvider.DETAILS_URI, null, null, new String[]{ query.getString("query") }, null);
        return cLoader;
    }
 
    @Override
    public void onLoadFinished(Loader<Cursor> arg0, Cursor c) {
        showLocations(c);
    }
 
    @Override
    public void onLoaderReset(Loader<Cursor> arg0) {
        // TODO Auto-generated method stub
    }
 
    private void showLocations(Cursor c){
        MarkerOptions markerOptions = null;
        LatLng position = null;
        mGoogleMap.clear();
        while(c.moveToNext()){
            markerOptions = new MarkerOptions();
            position = new LatLng(Double.parseDouble(c.getString(1)),Double.parseDouble(c.getString(2)));
            markerOptions.position(position);
            markerOptions.title(c.getString(0));
            mGoogleMap.addMarker(markerOptions);
        }
        if(position!=null){
            CameraUpdate cameraPosition = CameraUpdateFactory.newLatLng(position);
            mGoogleMap.animateCamera(cameraPosition);
        }
    }
}

14. Update the configuration file /res/xml/searchable.xml

<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:label="@string/app_name"
    android:hint="@string/search_hint"
    android:searchSettingsDescription="@string/search_settings"
 
    android:searchSuggestAuthority="com.blogspot.geekonjava.PlaceProvider"
    android:searchSuggestIntentAction="android.intent.action.VIEW"
    android:searchSuggestSelection=" ?"
    android:searchSuggestThreshold="2" >
 
</searchable>

15. Update the file AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.blogspot.geekonjava"
    android:versionCode="1"
    android:versionName="1.0" >
 
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
 
    <!-- Protect the map component of the application using application signature -->
    <permission
        android:name="com.blogspot.geekonjava.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />
 
    <!-- Allows to receive map -->
    <uses-permission android:name="com.blogspot.geekonjava.permission.MAPS_RECEIVE" />
 
    <!-- Used by the Google Maps Android API V2 to download map tiles from Google Maps servers -->
    <uses-permission android:name="android.permission.INTERNET" />
 
    <!-- Allows the Google Maps Android API V2 to cache map tile data in the device's external storage area -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 
    <!-- Allows the Google Maps Android API V2 to use WiFi or mobile cell data (or both) to determine the device's location -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 
    <!-- Allows the Google Maps Android API V2 to use the Global Positioning System (GPS)
    to determine the device's location to within a very small area -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 
    <!-- Allows to contact Google Serves -->
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
 
    <!-- Google Maps Android API V2 requires OpenGL ES version 2 -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
 
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.blogspot.geekonjava.MainActivity"
            android:label="@string/app_name"
            android:launchMode="singleTop" >
 
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
 
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>
 
            <!-- Points to searchable activity -->
            <meta-data android:name="android.app.default_searchable"
                android:value=".MainActivity" />
 
            <!-- Points to searchable meta data -->
            <meta-data android:name="android.app.searchable"
                android:resource="@xml/searchable"/>
 
        </activity>
 
        <provider
            android:name=".PlaceProvider"
            android:authorities="com.blogspot.geekonjava.PlaceProvider"
            android:exported="false" />
 
        <!-- Specifies the Android API Key, which is obtained from Google API Console -->
        <meta-data android:name="com.google.android.maps.v2.API_KEY"
            android:value="YOUR_ANDROID_API_KEY" />
    </application>
</manifest>
Note : Update “YOUR_ANDROID_API_KEY" on line 76 with the android key obtained in Step 4.


Make Animated Icons Using Javascript with mo.js

Mo.js, a really powerful motion graphics library for the web created by Oleg Solomka. you'll be able to do plenty of amazing things with it and these days we’d prefer to share our take on some icon animations using the library.



It would be extremely nice to be ready to animate icons simply to appear like Twitter’s heart animation, and once seeing this Dribbble shot by Daryl Ginn of a hybrid (this is “what Twitter’s like animation would seem like if it were on Facebook”), we needed to do to use mo.js together with Dave Gandy’s Font awesome web font and see what is done.


The icons that we are animating are actions wherever it makes sense to own an active state, like as an example the “favorite”, “like” or “upvote”. Although, theoretically, you may apply these quite effects to something, it extremely feels additional smart for these quite actions.

Download Source Code


Demo: You can check here also


Let’s have a glance at an example. therefore we’ve used Font awesome as icon font and include it in a button like this:

<button class="icobutton icobutton--thumbs-up">
 <span class="fa fa-thumbs-up"></span>
</button>
The designs include some resets and size definitions for the button.

You can currently define your animations as follows:

    var scaleCurve = mojs.easing.path('M0,100 L25,99.9999983 C26.2328835,75.0708847 19.7847843,0 100,0');
    var el = document.querySelector('.icobutton'),
 elSpan = el.querySelector('span'),
 // mo.js timeline obj
 timeline = new mojs.Timeline(),

 // tweens for the animation:

 // burst animation
 tween1 = new mojs.Burst({
  parent: el,
  duration: 1500,
  shape : 'circle',
  fill : [ '#988ADE', '#DE8AA0', '#8AAEDE', '#8ADEAD', '#DEC58A', '#8AD1DE' ],
  x: '50%',
  y: '50%',
  opacity: 0.6,
  childOptions: { radius: {20:0} },
  radius: {40:120},
  count: 6,
  isSwirl: true,
  isRunLess: true,
  easing: mojs.easing.bezier(0.1, 1, 0.3, 1)
 }),
 // ring animation
 tween2 = new mojs.Transit({
  parent: el,
  duration: 750,
  type: 'circle',
  radius: {0: 50},
  fill: 'transparent',
  stroke: '#988ADE',
  strokeWidth: {15:0},
  opacity: 0.6,
  x: '50%',     
  y: '50%',
  isRunLess: true,
  easing: mojs.easing.bezier(0, 1, 0.5, 1)
 }),
 // icon scale animation
 tween3 = new mojs.Tween({
  duration : 900,
  onUpdate: function(progress) {
   var scaleProgress = scaleCurve(progress);
   elSpan.style.WebkitTransform = elSpan.style.transform = 'scale3d(' + scaleProgress + ',' + scaleProgress + ',1)';
  }
 });

// add tweens to timeline:
timeline.add(tween1, tween2, tween3);

// when clicking the button start the timeline/animation:
el.addEventListener('mouseenter', function() {
 timeline.start();
});
Note that we are using a fixed size for the effects here. For a additional flexible approach, you may define the sizes dynamically.
Okay, now try your own animations; the probabilities are endless!
We hope you enjoyed these animations and notice them inspiring!