As far as I know, this cannot be done using the Google Maps API.
I think your best bet is to use a crowd-generated dataset like OpenStreetMap (OSM) .
You will need to configure your own spatial database (e.g. PostGIS ) and import the OSM data into the database.
You will then create a server API (hosted on a web server such as Tomcat or Glassfish ) to get the current location of the mobile phone, buffer the location with a specific radius to give you a round polygon, and do a spatial query through PostGIS to determine if the buffer intersects any roads (for example, paths labeled "highway = primary" or "highway = secondary", depending on what types of roads you want to include - see this site ) and return a true or false answer to the phone.
EDIT Aug 2015
Now the android-maps-utils library now has the PolyUtil.isLocationOnPath() method, which will allow you to perform this type of calculation inside your Android application, assuming that you have a set of points that make up the road (or any other line).
Here the code looks in the library :
public static boolean isLocationOnPath(LatLng point, List<LatLng> polyline, boolean geodesic, double tolerance) { return isLocationOnEdgeOrPath(point, polyline, false, geodesic, tolerance); }
To use this library, you need to add the library to your build.gradle :
dependencies { compile 'com.google.maps.android:android-maps-utils:0.4+' }
Then, when you have a point and your path, you will need to convert your lat / longs to LatLng objects (in particular, a LatLng point and List<LatLng> line , respectively), and then in your code call:
double tolerance = 10;
... to find out if your point is within 10 meters of your line.
For more information on how to use it, see the Getting Started Guide for this library.