Hiker’s Watch App

Vikram Mohanty
3 min readNov 3, 2020

Application based on android.

coding language used : Java

I assume that you have android studio downloaded. If not then you need to download it and set itup .Follow the link to download :

download

So first of all create a new project ,select an empty activity name it as HikersWatch or a name of your choice . Select language as Java and select android version as oreo 8.0 and click on create .

Now go to HikersWatch/app/res/layout/activity_main.xml

Find a image that you want to add as your background and save it in HikersWatch/app/res/drawable.

Now go back to activity_main.xml file add a image view from the palette to constraint layout in component tree.

Set the constraint layout width and layout height to 0dp.

In common attribute-> src_compact add the image saved in the drawable.

So now you have your image view ready .

Time to add other attributes.

Add a textview in the same way you added a image view. Now go to all attributes->

adjust it to fit in center and in text field write Hiker’s Watch and in text size field set it to 50sp.

Add another textview in same way and name it as latTextView for latitude. Now go to all attributes->

adjust it to left align and in text field write latitude and text size field set it to 20sp-30sp(according to your preference).

In the same way prepare text view for longitude, accuracy, altitude and address and name them accordingly.

Your final layout should look like this :

If you face any problem with layout you can refer to my github repo (link given at the end)

Go to src/android manifest and do the following changes as shown in the image :

Now move to HikersWatch/app/src/java/mainactivity.java

Here you can add the following code to mainactivity.java

LocationManager : This class provides access to the system location services. These services allow applications to obtain periodic updates of the device’s geographical location, or to be notified when the device enters the proximity of a given geographical location.

LocationListener : Used for receiving notifications from the LocationManager when the location has changed.

Open AVD manager and select the device with API27 . Run the app .Click on “…” and select location and set a point of your choice in the map and set location to see the information on the app. Change the location to see the changes in various fields in the app that you have added. Your final app should look like this :

Hope you did not face any problem with the app . If you had any problem you can feel free to go and have a look at the code from my github repo :

github

--

--