Android Example : Fetching Current Location with FusedLocationProviderAPI

marker

 

Fetching Location is one of the most useful features on mobile devices. In fact lot of apps completely rely on user’s location for their business, take Uber for example. This implies that it is very important to fetch user’s location accurately and seamlessly on mobile devices. In Android there are basically two methods to fetch user location

Android framework location APIs were the most reliable way of fetching location up until FusedLocationProviderApi was released. Fused location provider is found to be more accurate, fast and easy to implement. Above all Android doc itself encourages developers to migrate to Fused Location provider.

Continue reading

Android Example: Display Current Location on Google Map with FusedLocationProviderAPI

Maps in applications have taken customer experience to a whole new level. Whether its showing the current user location or showing the direction to your business office maps have always been very useful. The good news here is even though displaying the complete world map inside your app might sound a very complex task thanks to Google its ridiculously easy

Photo_1501961386074

In this tutorial we will deal with the basics of  Google Location and Map Android Integration, we will register our project in Google Developer Console and obtain the API key . Using the API key we will show the Map in our app and with the help of FusedLocationProvider API mark the current location on the map.

Continue reading

Android Example: Display Current Location on Google Map with FusedLocationProviderClient

This article is updated and uses the latest FusedLocationProviderClient API to fetch current location

Maps in mobile applications have taken customer experience to a whole new level. Whether its displaying the current location or showing directions to your business office, maps have always been very useful. The good news here is even though displaying the complete world map inside your app might sound a very complex task thanks to Google its ridiculously easy

In this tutorial we will deal with the basics of Google Location and Map APIs. We will register our project in Google Developer Console and obtain the API key . Using the API key we will show the Map in our app and with the help of FusedLocationProvider API mark the current location on the map.

Continue reading

Android Broadcast Receivers with Example

What are Broadcasts?

Consider a situation in which you are downloading a large file in your app and suddenly the battery goes critically low , you don’t want the download to stop abruptly and would like to show the user a notification/dialog so that he can pause the download.  Creating a service just to keep on checking the battery power would be too much work for a simple notification. What if the android system itself notifies you of any such system event like battery low or airplane mode.

Guess what?  It does!. And you can handle these events very efficiently.. These events are known as broadcasts and you need to handle them in a broadcast receiver. Your app can have its own custom broadcasts which it can send within the app or to other apps on the device to notify them of an event they might be interested in.

One common use case of  sending broadcasts within the same app is mentioned here:

Suppose you have updated your  profile details in an activity inside the app, you would like the updated changes to be reflected immediately in all the other active activities without having to refresh them. In this case you can send a broadcast informing the other activities that the profile details are updated

Continue reading

BroadcastReceiver in Android | With Example

BroadcastReceiver is one of the four basic Android Components. In this example we will be learning how to create a BroadcastReceiver and listen for broadcast. Before that let us first understand what are Broadcasts

What are Broadcasts?

Consider a situation in which you are downloading a large file in your app and suddenly the battery goes critically low , you don’t want the download to stop abruptly and would like to show the user a notification/dialog so that he can pause the download.  Creating a service just to keep on checking the battery power would be too much work for a simple notification. What if the android system itself notifies you of any such system event like battery low or airplane mode.

Guess what?  It does!. And you can handle these events very efficiently. These events are known as broadcasts and you need to handle them in a broadcast receiver. Your app can have its own custom broadcasts which it can send within the app or to other apps on the device to notify them of an event they might be interested in.

One common use case of  sending broadcasts within the same app is mentioned here:

Suppose you have updated your  profile details in an activity inside the app, you would like the updated changes to be reflected immediately in all the other active activities without having to refresh them. In this case you can send a broadcast informing the other activities that the profile details are updated

Continue reading