Android Useful Methods and Functions

A fully featured Android application has a lot of functionality going on to provide a user-friendly interface to the user. For example, we can Indicate if the device is still connected to a network of if connected is it Wifi or mobile network, check GPS status on the device, battery status like a battery percentage or if connected to power source etc. In this post, I am going to list some similar handy and useful methods which are needed most of the time in an Android application.

To give an idea I have listed methods which we will discuss further:

1) Check if Device is Connected to Network.
2) Check GPS Status of the device.
3) Show/ Remove Notification.
4) Convert Google Geocode Address Object into Comma Separated String.
5) Check Battery Status is it connected to Power.
6) Convert Date into a required format.

To keep these methods available to every activity in the application, its preferable to keep them in a Utils Class.

1) How to Check if Device is Connected to Network?

To check connectivity we will use ConnectivityManager service, this will return Network Info, type of network and other information. You can check more details here.

Also add permission in AndroidManifest file


This method will return an object in string format.

2) How to check if device GPS is turned On/ Off?

This method will use the LocationManager service.

3) How to create and remove Custome Notifications in Android Application?

Following method will show Notification, having big text and freeze enabled( Notification will not get removed even after user swipes ). We need NotificationManager service, you can read more about the Notification service here

Method to Remove Notifications

4) How to Convert Google Geocode Address Object into Comma Separated String.

After getting Address Object from Geocoder service we will pass it to the following method, which will return comma separated string of address. You can check Background Geolocation and Geocoder Application Example tutorial for information on these location services.

5) How to Check Battery Status is it connected to Power.

To check battery percentage we use BatteryManager, the following method will return battery percentage.

6) How to Get Formatted Date in Android Application?

Calendar.getInstance().getTime() gives



So we discussed some commonly used methods in Android application. These are parts of some my application. You may have a different approach for some functionalities, you can change and give feedback if for any suggestions or correction is most welcome 🙂

Leave a Reply

Notify of