Android Displaying Distance Duration and Route in Application Using Google Maps

Android Displaying Distance Duration and Route in Application Using Google Maps

In this article i going to share a tutorial about how to display distance, duration and route in your application using Google Maps. You guys pretty sure have been know about the navigation feature of Google Maps, right?. Look at Figure 1
This tutorial will showing something like that. Like Figure 1, you can see how long the distance and duration to the destination. Also you can see which route that recommend by Google Maps
From the Video, is this similar as what you're looking for? If yes, please kindly follow the next steps. But if not, it's also ok for me :D


1. Get the API KEY from Google
2. Start Development with Android Studio


2. Get the KEY and activating the Google Maps API
Open this link : , After in, click the GET API button at the top right side. Take a look at Figure 2
Next, create new project. The name of the project must be similar with your project in Android Studio. But it's up to you! It's ok. Take a look at Figure 3
+Create a new project
, Fill the project name and press button
. After your press the button enable api, you'll given a
Server Key
. This Server Key that will you use and set in your AndroidManifest. Take a look Figure 4
As you can see ad Figure 4, you have got the API KEY. You also can open the console by press the button GO TO CONSOLE. Take a look at Figure 5
You can change the name. Write whatever so make you easy to remember. Because next when you have much project, you'll confusing haha. private experience.
2. Start Development in Android Studio

Before start, the first thing you have to know is the endpoint and the json format. It makes you easy to create the model class. You can check the json format here :,115.18285993&destination=-8.1246437,115.3133908&sensor=false&mode=driving&alternatives=true

Several term inside the model that you'll create must be same as the attribute name of the respon json above.
Ok, let's start. In order you don't get confuse while following this tutorial, for a while, please kindly follow my project structure. Take a look at Figure 6
Let start create the class one by one. First give some permissions on your
and declare the API-KEY-SERVER that we have got.
Second, compile several libraries in your build.gradle (Module:app) that we'll use in this project. Look at the code below :


There are some models that we'll use in this tutorial, the function of there method is to do getter and setter. Let's create one by one.
This class used to take route's data from json
This class used to take LatLng from the Destination (End Location)
This class used to take all of Leg's data from json
This class used ti take LatLng's data from Origin (Start Location)


In this package contains several that used to make easy development proccess
This class contains variables that used as key in storing data in SharedPreference and Storing URL/Endpoint
This class used to parse JSON. In this class also contains method that create polyline
As previous tutorials, class LoggingInterceptor used to make easy for debugging
This class cointains method SharedPreferences that used to store data


In this package contains an interface. This interface contains method that i used to execute the URL/Endpoint that has been prepared


In this package only contains adapter class. The function of this adapter is set and show list object location


In this package contains only Activity classes
This class used to show all the destination list. Later, when we choose one location from the list, it will direct to the maps and show the route between origin and destination
This class will showing the destination, duration and route from the origin to the destination.
This class will showing the map include the marker from the list location that we have.
That's all the steps that you can follow to display distance, duration and route in Application using Google Maps.

If done, then running your project. Hope there is no error :D
Android Displaying Multiple Markers From Database

Android Displaying Multiple Markers From Database

This article will share you how to displaying multiple markers from database. Like the title data latitude and longitude will get from server (Server created with PHP and MySQL).

What is marker means?

Marker on Maps is a mark of a place on Google Maps. The main requirement in order to able to show the marker on Google maps are data
latitude and longitude
For example :
The coordinates of Badung Regency are -8.58193 (Latitude) and 115.177059 (Longitude). You also can check coordinates of your location on this web : Distancesto.
Ok, that's a short description about markers and its requirements, now i will share about creating the project.
To achieve the goal of this project, i create 2 projects, that are : 1 PHP project (for creating server) and 1 Android project (for client).

Creating Server

In this article i will create a simple server just for learning and not recommend to implementing in production project.
First you have to create your database structure and second create the php to connecting your project to your database.


I only use one table. And inside the table i have inserted the data of latitude and longitude. Take a look at the following image

PHP Project

There are two files in php project. First class for connect to database and the second class for displaying data location in JSON.


Please adjust your username, password and your database name.


The above class will displaying data in json. Here is the output of the above class :
See also : Create file Json Object and Array Using PHP

Android Project

I will create the project by using the default template of Android Studio. Fyi, i use Android Studio Versi 2.2.2, not the latest version.
First, click start a new android project.
Second, name your project by filling field
Application name
Company domain
Third, select your platform, in this case just check the
phone and tablet
Fourth, select the template that you want to use. Related with this project, just select
Google Maps Activity
Fifth, give name your activity, layout and title by filling the field
Activity name
Layout name
After that, click button

Library Gradle

I have added some libraries. Modify your gradle to be the same as bellow :

Generate API_KEY

In order to able to display Google Maps in your project, you have to generate the API_KEY in
Google Developer Console
. You can user the existing project, or create new project.
First, generate API_KEY by clicking button GET A KEY.
Second, you can use the existing project or create new project.
Third, copy your API_KEY and place in
meta-data androidManifest
Confuse? Take a look at the following meta-data in AndroidManifest file :


Please adjust your AndroidManifest to be same as below :
Okay, until here, you have done preparing your requirement for creating Google Maps in your application. Next we will create several java classes.

Create two classes as model to handle the data from json

This class used to handle one object data from json. The code look like the follows :

Because json that we will receive is an array, means more than one object, then one object in class
will created as list with class
If you confuse with json format array and json format object, please continue read here : Create file json format array and json format object using PHP MySQL.

Class Client and Interface

The following are two classes that define the main URL (client) and its part (endpoint).

if you clearly see the URL, it contains digits, right? These digits is the IP of my computer that connected with my local internet (Tethering from my phone).

Class Logging Interceptors

Class MainActivity

This class is the main class that used to displaying all data makers on Google Maps. The full code is show as bellow :

Okay, that's all. Running your project and hope works well.
Android How To Move To The Other Activity Using Intent

Android How To Move To The Other Activity Using Intent

In this tutorial, I will explain how to move from one activity to other activity by using Intent.
Intent have abstract description from the operation. Intent can used with
for calling new activity,
from send broadcastReceiver and
startService or bindService 
for communicate with background service.


Prepared 2 xml layout :
  1. activity_main.xml
  2. acitivity_second.xml
Preapre 2 Java classes :
The xml code for
, look likes this :
<?xmlversion="1.0"encoding="utf-8"?><RelativeLayoutxmlns:android=""xmlns: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="com.example.putuguna.projecttesting.MainActivity"><TextViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center"android:textAllCaps="true"android:text="Hello World! I am in the First Activity"/><Buttonandroid:id="@+id/btn_start"android:layout_width="match_parent"android:text="Start"android:layout_height="wrap_content"/></RelativeLayout>
, look likes this :
<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android=""android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:layout_weight="1"android:id="@+id/second_layout"android:layout_width="match_parent"android:layout_height="match_parent"android:text="HALLO YOU ARE IN THE SECOND ACTIVITY"android:gravity="center"/><Buttonandroid:id="@+id/btn_back"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="Back"/></LinearLayout>
After we created the layout, now modify our java classes. Create an onClick for the button that we used to calling new activity. The code of
, like the following :
packagecom.example.putuguna.projecttesting;importandroid.content.Intent;;importandroid.os.Bundle;importandroid.view.View;importandroid.widget.Button;publicclassMainActivityextendsAppCompatActivity{privateButtonmButtonStart;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//kita ambil ID yang ButtonmButtonStart=(Button)findViewById(;//We set the onClick of the button start//After that, we go to the next activity using intentmButtonStart.setOnClickListener(newView.OnClickListener(){@OverridepublicvoidonClick(Viewv){Intentintent=newIntent(MainActivity.this,SecondActivity.class);// means : From will going to go to the SecondActivity.javastartActivity(intent);}});}}
Modify your, like the following code :
packagecom.example.putuguna.projecttesting;importandroid.os.Bundle;;;importandroid.view.View;importandroid.widget.Button;/** * Created by putuguna on 17/06/16. */publicclassSecondActivityextendsAppCompatActivity{privateButtonmBtnBack;@OverrideprotectedvoidonCreate(@NullableBundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_second);//Ambil ID si Button BackmBtnBack=(Button)findViewById(;//Set on CLick si Button BackmBtnBack.setOnClickListener(newView.OnClickListener(){@OverridepublicvoidonClick(Viewv){onBackPressed();/*If you need to call the previous activity, just use onBackPressed()*/}});}}
To back to the previous page by using a button (not button back on your phone) just write
inside your onClick.
onBackPressed() is a default method that used to back to the previous Activity 

Ok, that's all
Tutorial Image Transition Look Likes On Google Play When Image Clicked

Tutorial Image Transition Look Likes On Google Play When Image Clicked

Today i will share about Image transition. This image transition is look likes newer google play transition. When you clicked the image, it look like come out from its place. And when you back to the previous activity, the image will be back to its place.
That effect using
. How can it come back to its place or frame? because it's using TAG that placed in Activity where the image will shown.


Compile the following libraries in your
build.gradle(Module : apps)
compile ''
compile ''
compile ''
The effect that we'll use is default from the
design support 23.4.0
. Next, prepare some xml layouts and java classes :
  1. > We set the image to the imageview
  2. > Object where the image place before set to the ImageView
  3. > We set listview with adapter
  4. > The image will appears here
  5. activity_detail_layout.xml > The layout of
  6. activity_main.xml > The layout of
  7. item_row.xml > The layout of
Next we modify every xml layout and classed, like the following codes :
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=""
 android:orientation="vertical" android:layout_width="match_parent"
 android:text="Name Of Image"/><TextView
 android:text="Name Of owner"/><TextView
Second, modify your

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=""
 android:text="The Name of Image"/><TextView
 android:text="The owner of picture"/></LinearLayout></LinearLayout></></RelativeLayout>
Third, modify your

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=""
 android:text="This is the items"/><
Next process is write code for java classes. First we write code for model called
 * Created by putuguna on 02/06/16.
 */publicclassImageModel {
 privateString mImage;
 privateString mImageName;
 privateString mImageOwnerName;
 privateString mDesc;
 publicImageModel(StringmImage, StringmImageName, StringmImageOwnerName, StringmDesc) {
 this.mImage = mImage;
 this.mImageName = mImageName;
 this.mImageOwnerName = mImageOwnerName;
 this.mDesc = mDesc;
 publicImageModel() {
 publicStringgetmImage() {
 return mImage;
 publicvoidsetmImage(StringmImage) {
 this.mImage = mImage;
 publicStringgetmImageName() {
 return mImageName;
 publicvoidsetmImageName(StringmImageName) {
 this.mImageName = mImageName;
 publicStringgetmImageOwnerName() {
 return mImageOwnerName;
 publicvoidsetmImageOwnerName(StringmImageOwnerName) {
 this.mImageOwnerName = mImageOwnerName;
 publicStringgetmDesc() {
 return mDesc;
 publicvoidsetmDesc(StringmDesc) {
 this.mDesc = mDesc;
Next, modify your
. Please take a look clearly to the TAG_IMAGE_NAME. That tag taken from, it will lead the image back to the previous index after it back from
 * Created by putuguna on 02/06/16.
 */publicclassImageAdapterextendsRecyclerView.Adapter<ImageAdapter.ViewHolder> {
 privateList<ImageModel> mListImage;
 privateContext mContext;
 publicImageAdapter(List<ImageModel>mListImage, ContextmContext) {
 this.mListImage = mListImage;
 this.mContext = mContext;
 @OverridepublicViewHolderonCreateViewHolder(ViewGroupparent, intviewType) {
 View view =LayoutInflater.from(parent.getContext()).inflate(R.layout.item_row, parent,false);
 ViewHolder holder =newViewHolder(view);
 return holder;
 @OverridepublicvoidonBindViewHolder(ViewHolderholder, intposition) {
 @OverridepublicintgetItemCount() {
 return mListImage.size();
 publicImageView mImageProduct;
 publicTextView mNameOfImage;
 publicTextView mNameOfOwner;
 publicViewHolder(ViewitemView) {
 mImageProduct = (ImageView) itemView.findViewById(;
 mNameOfImage = (TextView) itemView.findViewById(;
 mNameOfOwner = (TextView) itemView.findViewById(;
 @OverridepublicvoidonClick(Viewv) {
 int position = getAdapterPosition();
 ActivityOptionsCompat options =ActivityOptionsCompat.makeSceneTransitionAnimation(
 ((Activity)mContext), mImageProduct, SecondActivity.TAG_IMAGE_NAME);
 Intent intent =newIntent(mContext, SecondActivity.class);
 intent.putExtra("name-image", mListImage.get(position).getmImageName());
 intent.putExtra("owner-name", mListImage.get(position).getmImageOwnerName());
 intent.putExtra("desc", mListImage.get(position).getmDesc());
 ActivityCompat.startActivity(((Activity)mContext), intent, options.toBundle());
Modify your
. Take a look to the TAG_IMAGE_NAME, that will leads the image back to previous place or index after press the back button from
Flow : After you click the image from RecyclerView, automatically it brings a TAG for the image that clicked. When you press button back from SecondActivity, the TAG that brought by Image will searching where its place before.
publicclassSecondActivityextendsAppCompatActivity {
 privateImageView mImage;
 privateTextView mNameOfImage;
 privateTextView mNameOfOwner;
 privateTextView mDesc;
 @OverrideprotectedvoidonCreate(BundlesavedInstanceState) {
 mImage = (ImageView) findViewById(;
 mNameOfImage = (TextView) findViewById(;
 mNameOfOwner = (TextView) findViewById(;
 mDesc = (TextView) findViewById(;
 String image = getIntent().getStringExtra("image");
 String imageName = getIntent().getStringExtra("name-image");
 String ownerName = getIntent().getStringExtra("owner-name");
 String desc = getIntent().getStringExtra("desc");
 ViewCompat.setTransitionName(mImage, TAG_IMAGE_NAME);
Last, modify your
publicclassMainActivityextendsAppCompatActivity {
 privateRecyclerView mRecyclerView;
 privateList<ImageModel> mList;
 privateImageAdapter mAdapter;
 @OverrideprotectedvoidonCreate(BundlesavedInstanceState) {
 mRecyclerView = (RecyclerView) findViewById(;
 mList =newArrayList<>();
 mList.add(newImageModel(String.valueOf(R.drawable.drink1), "Drink 1", " Putu Joli Artaguna", "This is the best drink in the world."));
 mList.add(newImageModel(String.valueOf(R.drawable.drink2), "Drink 2", " putu guna", "This is the best drink in the world."));
 mList.add(newImageModel(String.valueOf(R.drawable.drink3), "Drink 3", " Putu Guna", "This is the best drink in the world."));
 mList.add(newImageModel(String.valueOf(R.drawable.drink4), "Drink 4", " Putu Guna", "This is the best drink in the world."));
 mList.add(newImageModel(String.valueOf(R.drawable.drink5), "Drink 5", " Putu Guna", "This is the best drink in the world."));
 mList.add(newImageModel(String.valueOf(R.drawable.paket1), "Packet 1", "", "This is the best packet in the world."));
 mList.add(newImageModel(String.valueOf(R.drawable.paket2), "Packet 2", "", "This is the best packet in the world."));
 mList.add(newImageModel(String.valueOf(R.drawable.paket3), "Packet 3", "", "This is the best packet in the world."));
 mList.add(newImageModel(String.valueOf(R.drawable.paket5), "Packet 5", "", "This is the best packet in the world."));
 mList.add(newImageModel(String.valueOf(R.drawable.drink1), "Drink 1", " Putu Joli Artaguna", "This is the best drink in the world."));
 mList.add(newImageModel(String.valueOf(R.drawable.drink2), "Drink 2", "", "This is the best drink in the world."));
 mList.add(newImageModel(String.valueOf(R.drawable.drink3), "Drink 3", "", "This is the best drink in the world."));
 mAdapter =newImageAdapter(mList, this);
 RecyclerView.LayoutManager mLayoutManager =newLinearLayoutManager(getApplicationContext());
That's all, hope running well.

Get a Game Cheat Trick with the new free online hack tool. Try it today!
Top 6 Advantages Of Online Education

Top 6 Advantages Of Online Education

The education system is changing day by day, perhaps we will see a completely new educational system in coming decades. Online education is bringing a big revolution in the educational system. With the help of online education study material or learning resources are easily available in our hand. The interesting part is most them are available for absolutely free. There are many advantages of online education, in this context, we will discuss only the major parts.
If you search for such good and reputed educational sites then:

#1 Lower total costs:

One of the main advantages of online education are, it reduces the total cost of education. Because the online program can be a more affordable option than traditional colleges.
For example, there are no communicating costs and no required of course material such as textbooks because those materials are often available for free online in the form of soft copy.

#2 More comfortable learning environment:

Personally, I prefer this advantages of online education. Because it is more comfortable learning environment than a traditional educational system. I am sure you will definitely agree with me.
Lectures and others study materials are electronically sent to the students who will then read them and complete assignments. The student will not have to fight traffic, find parking spaces, live work, early to go classes or miss important family time.

#3 Continue in your profession:

Online education helps to save a lot of valuable time and its flexibility allow you to continue your profession. The student who is working in different organizations can study more and more with the help of online education along with their works. This is really cool advantages of online education for professionals. Students in online education can take classes at any time in 24 hours. So the online education system is beneficial for every person.

#4 Networking opportunities:

With online education, you get the opportunity to network with individuals all around the country even around the world whereas on-campus program typically limits you to our small local area.

#5 Better for the woman:

The benefits of online education to a woman it’s more than men for the reason that woman faces many difficulties in learning such as transportation etc. So with the help of online education woman can get higher education at their doorstep.

#6 No pressure like traditional education:

Online education is more flexible than traditional education. It is totally pressured free from our social life. You can learn from anywhere in the world even you could learn when you traveling by bus or cabs.
Traditional education is tedious. You have to do everything in time. If you miss an important class in traditional education you will not know what others student learn. But in online education, there is no chance to miss any lesson. Everything is in your hand whenever you get the time you can see any lectures among many lectures.

Finally, I would like to say that the future of online education is bright.Although there is a disadvantage also but advantages of online education is stronger than it’s limitation The reason behind this is that student wants comfortable learning. In these days students want to read books on laptop or tablet and the professor is on a computer or on mobile. So they can pause their event and stop their professor with the help of online education.
How to Design And Edit Any Web Page From A Browser

How to Design And Edit Any Web Page From A Browser

Do you know, you can edit any web page from a browser directly? Yes, you can do it right from your chrome browser using Developer Tools. This does not only work for chrome browser but also work for other standard browsers like Firefox and Safari. In this article, we will use only chrome browser. You can not only just edit any web page you can also design that web page.In this tutorial,
You can not only just edit any web page you can also design that web page.In this tutorial, I will show you these steps how to design and edit any web page from a browser. Just you need to know some basic of HTML and CSS. If you don’t have basic about this topic then you can check They have a great tutorial about HTML and CSS and it is enough for beginners.

How to edit any web page from a browser?

How to design a web page from a browser?

Remember you can edit any web page from a browser but this change is not permanent. When you reload the browser you will see it’s default design or default text. This option is helpful for learning purpose. If you chang some certain element or design, then how it will appear in the browser you can check it directly from your browser. One who is learning web development or designing it is good practice to use Developer Tools for them. It will help you to learn faster.
How To Configure MailPoet WordPress Newsletter Plugin Step By Step

How To Configure MailPoet WordPress Newsletter Plugin Step By Step

MailPoest newsletter plugin for WordPress provides the free email marketing services. Which you can control from your WordPress sites directly. It allows you to add subscription form in the widgets section to manage your subscriber. MailPoet is the absolutely free plugin you can operate a bunch of stuff like managing subscriber, creating a newsletter, send newsletter and also you can do your custom design form. In this WordPress tutorial, we will see how to configure MailPoet WordPress newsletter plugin. You don’t need to install any other plugin to avail this services.
Now we will set up MailPoet newsletter step by step:

MailPoet installation:

Configure MailPoet WordPress newsletter plugin:

MailPoet “Forms” set up:

Signup confirmation settings:

  • After saving the forms click on the “List of forms”
  • Now click on the “Signup conformation” tab
  • Rewrite the default text if you wish to do that
  • Now “Save settings”

“Send with…” set up:

  • Now go to “Send with..” tab
  • Select any one of them “Your own website” or “Third party”
  • Choose delivery method
  • You may check “Test method”. Just click on “Send a test mail” that will send a test mail to your inbox.
  • If do not understand the above settings then leave it default.
  • Save Settings


  • Got to “Advanced” tab
  • Select “Roles and permissions”
  • Set “Reply-to name & email”
  • choose “Bounce Email” if you wish
  • Set up “Subscribers can edit their profile” according to your choice
  • Otherwise, leave it all default
  • Now click on “Save settings”

Configure MailPoet WordPress newsletter plugin Subscribers list:

  • Click on “Subscribers” on the MailPoet panel
  • The go to “Edit Lists” option
  • You will see default list “My first list”. You may delete that default list or edit it.
  • Let us edit this default list and give named it “Smallseoblog Subscribers”
  • Rewrite the “Description” 
  • Now click on “Update list”

Add subscriber manually:

Adding signup forms to the sidebar:

Note: Before going further now at first check the signup form. Go to your website and fill the signup form and click on “Subscribe” button to check the form is working correctly. If the form is working correctly then you will get an email notification from your website in your inbox.

Newsletter configuration:

Add Themes:

Add images:

Set you own styles:

Add social bookmarks:

  • Go to “Content” besides images tab
  • Drag and drop “Social bookmarks” where you want to show your social media links
  • Add your social media links in the given area
  • Choose the social media icon
  • Then click on “Done”

Send preview:

When all set up is completed then its time to check the email configure correctly. So now we will check a preview.

Send the email to the subscriber:

This is the final step and we will configure MailPoet WordPress newsletter plugin. Now, we will send the email to the subscribers. Although if your newsletter is not ready then save it as a draft.
Here is link to a sample newsletter which setup using MailPoet: Sample Newsletter

MailPoet is a great free newsletter services provider. If you have a small subscriber list then free version of MailPoset is good for you, otherwise, go for the premium version. So we configure MailPoet WordPress newsletter plugin correctly, still if you have any doubt regarding newsletter set up mention it in the comment section.