// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/GPSApplication.java
// public static String FILE_EMPTY_GPX;
// 
// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/GPSApplication.java
// public static String FILE_EMPTY_KML;
// 
// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/GPSApplication.java
// public static final String FILETYPE_KML         = ".kml";
// 
// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/GPSApplication.java
// public static final String FILETYPE_GPX         = ".gpx";


import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import static eu.basicairdata.graziano.gpslogger.GPSApplication.FILE_EMPTY_GPX;
import static eu.basicairdata.graziano.gpslogger.GPSApplication.FILE_EMPTY_KML;
import static eu.basicairdata.graziano.gpslogger.GPSApplication.FILETYPE_KML;
import static eu.basicairdata.graziano.gpslogger.GPSApplication.FILETYPE_GPX;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import androidx.core.content.FileProvider;
        return (externalViewerList.isEmpty());
    }

    /**
     * Creates the ExternalViewer list basing on the research criteria.
     * The criteria are defined into this method.
     * The list of ExternalViewer are stored here into this ExternalViewerChecker class,
     * and can be obtained from outside using the getExternalViewersList() method.
     */
    public void makeExternalViewersList() {
        final PackageManager pm = context.getPackageManager();

        externalViewerList = new ArrayList<>();
        ArrayList<FileType> fileTypeList = new ArrayList<>();

        fileTypeList.add(new FileType(null, "application/gpx+xml", FILETYPE_GPX));                      // The preferred format first
        fileTypeList.add(new FileType(null, "application/vnd.google-earth.kml+xml",  FILETYPE_KML));

        // We can add new MimeTypes, also with filtered lists!
        // for example this one:
//        ArrayList<String> gpxList = new ArrayList<>();
//        gpxList.add("com.vecturagames.android.app.gpxviewer");
//        fileTypeList.add(new FileType(gpxList, "application/gpx+xml", FILETYPE_GPX));

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        for (FileType ft : fileTypeList) {
            //intent.setType(ft.mimeType);

// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/GPSApplication.java
// public static String FILE_EMPTY_GPX;
// 
// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/GPSApplication.java
// public static String FILE_EMPTY_KML;
// 
// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/GPSApplication.java
// public static final String FILETYPE_KML         = ".kml";
// 
// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/GPSApplication.java
// public static final String FILETYPE_GPX         = ".gpx";


// Path: app/src/main/java/eu/basicairdata/graziano/gpslogger/ExternalViewerChecker.java
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import static eu.basicairdata.graziano.gpslogger.GPSApplication.FILE_EMPTY_GPX;
import static eu.basicairdata.graziano.gpslogger.GPSApplication.FILE_EMPTY_KML;
import static eu.basicairdata.graziano.gpslogger.GPSApplication.FILETYPE_KML;
import static eu.basicairdata.graziano.gpslogger.GPSApplication.FILETYPE_GPX;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import androidx.core.content.FileProvider;

        return (externalViewerList.isEmpty());
    }

    /**
     * Creates the ExternalViewer list basing on the research criteria.
     * The criteria are defined into this method.
     * The list of ExternalViewer are stored here into this ExternalViewerChecker class,
     * and can be obtained from outside using the getExternalViewersList() method.
     */
    public void makeExternalViewersList() {
        final PackageManager pm = context.getPackageManager();

        externalViewerList = new ArrayList<>();
        ArrayList<FileType> fileTypeList = new ArrayList<>();

        fileTypeList.add(new FileType(null, "application/gpx+xml", FILETYPE_GPX));                      // The preferred format first
        fileTypeList.add(new FileType(null, "application/vnd.google-earth.kml+xml",  FILETYPE_KML));

        // We can add new MimeTypes, also with filtered lists!
        // for example this one:
//        ArrayList<String> gpxList = new ArrayList<>();
//        gpxList.add("com.vecturagames.android.app.gpxviewer");
//        fileTypeList.add(new FileType(gpxList, "application/gpx+xml", FILETYPE_GPX));

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        for (FileType ft : fileTypeList) {
            //intent.setType(ft.mimeType);

            File file = new File(ft.mimeType.equals(FILETYPE_GPX) ? FILE_EMPTY_GPX : FILE_EMPTY_KML);