Android app development: click a ListView item programmatically

I’m going to share a code snippet that you may use to programmatically click a ListView item in your Android app. This will not simply highlight the desired ListView item, but also trigger the onItemClick listener. This code is what I placed in a Fragment’s onLoadFinished() method:

Simply replace the default_position value with the […]

Read More

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

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: underline text in your app

When I need to underline text in an app that I’m developing, I like doing it programmatically. The code is in the Java file, not in the XML. Maybe we should make a function for this where we pass the ID of the TextView whose content we’d like to underline.

Disadvantages in this method: […]

Read More