Saturday, 10 April 2021

Hiker Watch (Location Tracker) using Java

 

Image Source : techlog360

Creating a Hiker Watch.

Interested in App Development but frightened how to get started ?...Are you scared if Java is too tough? Well..to enter in this amazing World of development, we all just need a push. So here I am with a simple but exciting Android App for beginners...Lets dive into it guys!..

It's all more easy than expected.

What is Hiker Watch?

It is a Single Activity Android app which could be particularly used by hikers built on Android Studio Framework using Java. It tracks user's location and give details like Latitude, Longitude, Accuracy, Altitude, Address Etc.

ToDos:

  1. Create an android project on Android Studio.
  2. Add internet and network permissions in Manifest file.
  3. Design xml file for UI.
  4. Use Location Managers, location listeners , GeoCoder in java file for tracking location.(By default: MainActivity.java)
So, this is what we are going to do, I will take you through the procedure of how we can build something like this.

(Imp : A link for the Github repository is also added at last.)

1. Adding permissions : 

Open AndroidManifest.xml file from app -> manifests -> AndroidManifest.xml


Add these two permissions:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>


Don't forget to add these, otherwise the app may not work properly.

2. Preparing xml file :

All the UI task is handled under this. Here we will add Background Image and Text Views to our app from the palette at left.
Just drag and add the elements you want. Before doing so, add an appropriate layout too. I used Constraint layout in mine.

Open xml file:
app -> res -> layout -> activity_main.xml(Default)

My UI looks something like this:



Blue print of UI


(You can add more of your creative skills here :D)

3. Add Location listeners, location Managers and Geocoder :

Who would like to be tracked without being asked? Obviously, no one!
So, it is very essential for you to add location permission from the user.

  • Implement the permission part and add onRequestPermissionResult().
  • Add Location Manager.
  • Add Location Listener to regularly get location updates
  • Create an object of GeoCoder to get information about Address like Postal code, Locality, Country Name and the list continues...
For better understanding, you can have a look at developer.android.com. This site is a boon for developers! 💖

Run your app. If you are testing on an android device, make your to give location permissions and turn on the GPS!

You should see something like this on your Screen : 

(Yeah! I am a Safety freak , 👀 so I hided some part of my Address.. :D)

Kudos folks!!❤ Here we completed a short tour to our first Android App!!.. I am sure it was simple enough.. :D

For better understanding, check out my repo:


Thanks!!

SORTING ALGORITHMS

Always messes  with different sorting algorithms?? So, here I am again with my tutorial Blog. So, without wasting much of time, have a sip o...