Android Open Source - Geotrackin File Logger Factory

From Project

Back to project page Geotrackin.


The source code is released under:

GNU General Public License

If you think the Android project Geotrackin listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

*    This file is part of GPSLogger for Android.
*//from  w w w  .  j a  v a 2s.  c o  m
*    GPSLogger for Android is free software: you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation, either version 2 of the License, or
*    (at your option) any later version.
*    GPSLogger for Android is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    GNU General Public License for more details.
*    You should have received a copy of the GNU General Public License
*    along with GPSLogger for Android.  If not, see <>.

package com.geotrackin.gpslogger.loggers;

import android.content.Context;
import com.geotrackin.gpslogger.common.AppSettings;
import com.geotrackin.gpslogger.common.Session;
import com.geotrackin.gpslogger.common.Utilities;
import com.geotrackin.gpslogger.loggers.customurl.HttpUrlLogger;

import java.util.ArrayList;
import java.util.List;

public class FileLoggerFactory {
    public static List<IFileLogger> GetFileLoggers(Context context) {
        File gpxFolder = new File(AppSettings.getGpsLoggerFolder());
        if (!gpxFolder.exists()) {

        List<IFileLogger> loggers = new ArrayList<IFileLogger>();

        if (AppSettings.shouldLogToGpx()) {
            File gpxFile = new File(gpxFolder.getPath(), Session.getCurrentFileName() + ".gpx");
            loggers.add(new Gpx10FileLogger(gpxFile, Session.shouldAddNewTrackSegment(), Session.getSatelliteCount()));

        if (AppSettings.shouldLogToKml()) {
            File kmlFile = new File(gpxFolder.getPath(), Session.getCurrentFileName() + ".kml");
            loggers.add(new Kml22FileLogger(kmlFile, Session.shouldAddNewTrackSegment()));

        if (AppSettings.shouldLogToPlainText()) {
            File file = new File(gpxFolder.getPath(), Session.getCurrentFileName() + ".txt");
            loggers.add(new PlainTextFileLogger(file));

        if (AppSettings.shouldLogToOpenGTS()) {
            loggers.add(new OpenGTSLogger());

        if (AppSettings.shouldLogToCustomUrl()) {
            float batteryLevel = Utilities.GetBatteryLevel(context);
            String androidId = Utilities.GetAndroidId(context);
            loggers.add(new HttpUrlLogger(AppSettings.getCustomLoggingUrl(), Session.getSatelliteCount(), batteryLevel, androidId));

        return loggers;

Java Source Code List