/** * Searches a map in user's Google Maps. * * @param title the title of map * @param activity activity to get context * @param isDelete whether delete the map of this track in the Google Maps * @return true means find the map */ private static boolean searchMapByTitle(String title, Activity activity, boolean isDelete) { Context context = activity.getApplicationContext(); MapsClient mapsClient = new MapsClient( GDataClientFactory.getGDataClient(context), new XmlMapsGDataParserFactory(new AndroidXmlParserFactory())); ArrayList<MapsMapMetadata> mapData = getMaps(context, mapsClient); for (MapsMapMetadata oneData : mapData) { if (oneData.getDescription().indexOf(DOCUMENT_NAME_PREFIX) > -1 && oneData.getTitle().equals(title)) { if (isDelete) { try { mapsClient.deleteEntry( oneData.getGDataEditUri(), AccountManager.get(context) .blockingGetAuthToken(getAccount(context), MapsConstants.SERVICE_NAME, false)); return true; } catch (Exception e) { Log.d(EndToEndTestUtils.LOG_TAG, "Unable to drop map", e); return false; } } return true; } } return false; }
/** * Removes old tracks on Google Maps created by MyTracks test. * * @param activity */ public static void deleteTracksOnGoogleMaps(Activity activity) { Context context = activity.getApplicationContext(); MapsClient mapsClient = new MapsClient( GDataClientFactory.getGDataClient(context), new XmlMapsGDataParserFactory(new AndroidXmlParserFactory())); ArrayList<MapsMapMetadata> mapData = getMaps(context, mapsClient); for (MapsMapMetadata oneData : mapData) { try { mapsClient.deleteEntry( oneData.getGDataEditUri(), AccountManager.get(context) .blockingGetAuthToken(getAccount(context), MapsConstants.SERVICE_NAME, false)); } catch (Exception e) { Log.d(EndToEndTestUtils.LOG_TAG, "Unable to drop map", e); } } }