Android app codes for Google Maps with clustering

I prepared Android app codes with Google Maps and clustering feature. Feel free to use these as basis for your new projects. They are on GitHub: [1] Default Map Markers: catzie/SimpleAndroidMapClustering   [2] Custom Map Markers: catzie/Simple-Android-Map-Clustering-with-Custom-Markers   I simply took the necessary classes and res files from Android Maps Utility demo, and then placed […]

Read More

Android Maps: Get current location coordinates with Google API Client Builder

To get your current location via Google Map in an Android app, this was how we do it:

Stop. Don’t use that! The method GoogleMap.getMyLocation() is deprecated. Instead, we need to use FusedLocationApi and the callback onLocationChanged(). Here’s an example code that works for me ( consider copying the contents of onResume() into onStart() […]

Read More

Android Development: Permission denied when running ./gradlew in Mac

I’m using a Mac at the moment to work on my Android app projects. For some reason I need to run ./gradlew in the terminal, but I was getting this error: -bash: ./gradlew: Permission denied To fix this, what I did was run the following commands:

After those commands, my Mac downloaded numerous files […]

Read More

Android NetworkOnMainThreadException at StrictMode fix (with deprecated methods used)

A JSON Parser developed by some members of the Android dev team. But a few weeks after completion of the parser, several methods became deprecated. And when we use that parser, we get errors. Part of the stack trace is as follows:

Not sure if the NetworkOnMainThreadException is being thrown because of the deprecated […]

Read More

Android/Java: get variable data type

For some reason you might need to get the data type of your Java variable. Here’s an example of what you can try:

Then do whatever you like with data_type, whose value should be “String”. 🙂

Read More

Get device’s IMEI in Android app development

Here’s the content of my MainActivity class where I log the IMEI of my test device.

You also need to add this permission to your AndroidManifest.xml file:

Place it inside the <manifest></manifest> tag, but same level as <application></application>. Source: How to get the device’s IMEI/ESN programmatically in android?

Read More

Android: open web page in a browser

To open a web page in an Android app, we need to create a new Intent and start a new Activity with it. Here’s a Java method that we can re-use:

Just pass the URL of the web page you’d like to open to this method. Source: How to open a website when a […]

Read More