src/main/java/de/dennisguse/opentracks/util/IntentDashboardUtils.java
public static void startDashboard(Context context, boolean isRecording, String targetPackage, String targetClass, Track.Id... trackIds) {
        if (trackIds.length == 0) {
            return;
        }

        String trackIdList = ContentProviderUtils.formatIdListForUri(trackIds);

        ArrayList<Uri> uris = new ArrayList<>();
        uris.add(TRACK_URI_INDEX, Uri.withAppendedPath(TracksColumns.CONTENT_URI, trackIdList));
        uris.add(TRACKPOINTS_URI_INDEX, Uri.withAppendedPath(TrackPointsColumns.CONTENT_URI_BY_TRACKID, trackIdList));
        uris.add(MARKERS_URI_INDEX, Uri.withAppendedPath(MarkerColumns.CONTENT_URI_BY_TRACKID, trackIdList));

        Intent intent = new Intent(ACTION_DASHBOARD);
        intent.putExtra(EXTRAS_PROTOCOL_VERSION, CURRENT_VERSION);

        intent.putParcelableArrayListExtra(ACTION_DASHBOARD_PAYLOAD, uris);

        intent.putExtra(EXTRAS_SHOULD_KEEP_SCREEN_ON, PreferencesUtils.shouldKeepScreenOn());
        intent.putExtra(EXTRAS_SHOW_WHEN_LOCKED, PreferencesUtils.shouldShowStatsOnLockscreen());
        intent.putExtra(EXTRAS_OPENTRACKS_IS_RECORDING_THIS_TRACK, isRecording);
        if (isRecording) {
            intent.putExtra(EXTRAS_SHOW_FULLSCREEN, PreferencesUtils.shouldUseFullscreen());
        }

        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        ClipData clipData = ClipData.newRawUri(null, uris.get(TRACK_URI_INDEX));
        clipData.addItem(new ClipData.Item(uris.get(TRACKPOINTS_URI_INDEX)));
        clipData.addItem(new ClipData.Item(uris.get(MARKERS_URI_INDEX)));
        intent.setClipData(clipData);

        if ((targetPackage != null) && (targetClass != null)) {
            Log.i(TAG, "Starting dashboard activity with explicit intent (package=" + targetPackage + ", class=" + targetClass + ")");
            intent.setClassName(targetPackage, targetClass);
        } else {
            Log.i(TAG, "Starting dashboard activity with generic intent (package=" + targetPackage + ", class=" + targetClass + ")");
        }

        context.startActivity(intent);
    }
/**
     * Send intent to show tracks on a map (needs an another app) as resource URIs.
     * By providing a targetPackage and targetClass an explicit intent can be sent,
     * thus bypassing the need for the user to select an app.
     */
Send intent to show tracks on a map (needs an another app) as resource URIs.
By providing a targetPackage and targetClass an explicit intent can be sent,
thus bypassing the need for the user to select an app.
Send intent to show tracks on a map ( needs an another app ) as resource URIs . By providing a targetPackage and targetClass an explicit intent can be sent thus bypassing the need for the user to select an app .
public static void startDashboard(Context context, boolean isRecording, String targetPackage, String targetClass, Track.Id... trackIds) {
        if (trackIds.length == 0) {
            return;
        }
        String trackIdList = ContentProviderUtils.formatIdListForUri(trackIds);
        ArrayList<Uri> uris = new ArrayList<>();
        uris.add(TRACK_URI_INDEX, Uri.withAppendedPath(TracksColumns.CONTENT_URI, trackIdList));
        uris.add(TRACKPOINTS_URI_INDEX, Uri.withAppendedPath(TrackPointsColumns.CONTENT_URI_BY_TRACKID, trackIdList));
        uris.add(MARKERS_URI_INDEX, Uri.withAppendedPath(MarkerColumns.CONTENT_URI_BY_TRACKID, trackIdList));
        Intent intent = new Intent(ACTION_DASHBOARD);
        intent.putExtra(EXTRAS_PROTOCOL_VERSION, CURRENT_VERSION);
        intent.putParcelableArrayListExtra(ACTION_DASHBOARD_PAYLOAD, uris);
        intent.putExtra(EXTRAS_SHOULD_KEEP_SCREEN_ON, PreferencesUtils.shouldKeepScreenOn());
        intent.putExtra(EXTRAS_SHOW_WHEN_LOCKED, PreferencesUtils.shouldShowStatsOnLockscreen());
        intent.putExtra(EXTRAS_OPENTRACKS_IS_RECORDING_THIS_TRACK, isRecording);
        if (isRecording) {
            intent.putExtra(EXTRAS_SHOW_FULLSCREEN, PreferencesUtils.shouldUseFullscreen());
        }
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        ClipData clipData = ClipData.newRawUri(null, uris.get(TRACK_URI_INDEX));
        clipData.addItem(new ClipData.Item(uris.get(TRACKPOINTS_URI_INDEX)));
        clipData.addItem(new ClipData.Item(uris.get(MARKERS_URI_INDEX)));
        intent.setClipData(clipData);
        if ((targetPackage != null) && (targetClass != null)) {
            Log.i(TAG, "Starting dashboard activity with explicit intent (package=" + targetPackage + ", class=" + targetClass + ")");
            intent.setClassName(targetPackage, targetClass);
        } else {
            Log.i(TAG, "Starting dashboard activity with generic intent (package=" + targetPackage + ", class=" + targetClass + ")");
        }
        context.startActivity(intent);
    }
public static void startDashboard ( Context context , boolean isRecording , String targetPackage , String targetClass , Track . Id ... trackIds ) { if ( trackIds . length == 0 ) { return ; } String trackIdList = ContentProviderUtils . formatIdListForUri ( trackIds ) ; ArrayList < Uri > uris = new ArrayList < > ( ) ; uris . add ( TRACK_URI_INDEX , Uri . withAppendedPath ( TracksColumns . CONTENT_URI , trackIdList ) ) ; uris . add ( TRACKPOINTS_URI_INDEX , Uri . withAppendedPath ( TrackPointsColumns . CONTENT_URI_BY_TRACKID , trackIdList ) ) ; uris . add ( MARKERS_URI_INDEX , Uri . withAppendedPath ( MarkerColumns . CONTENT_URI_BY_TRACKID , trackIdList ) ) ; Intent intent = new Intent ( ACTION_DASHBOARD ) ; intent . putExtra ( EXTRAS_PROTOCOL_VERSION , CURRENT_VERSION ) ; intent . putParcelableArrayListExtra ( ACTION_DASHBOARD_PAYLOAD , uris ) ; intent . putExtra ( EXTRAS_SHOULD_KEEP_SCREEN_ON , PreferencesUtils . shouldKeepScreenOn ( ) ) ; intent . putExtra ( EXTRAS_SHOW_WHEN_LOCKED , PreferencesUtils . shouldShowStatsOnLockscreen ( ) ) ; intent . putExtra ( EXTRAS_OPENTRACKS_IS_RECORDING_THIS_TRACK , isRecording ) ; if ( isRecording ) { intent . putExtra ( EXTRAS_SHOW_FULLSCREEN , PreferencesUtils . shouldUseFullscreen ( ) ) ; } intent . addFlags ( Intent . FLAG_GRANT_READ_URI_PERMISSION ) ; ClipData clipData = ClipData . newRawUri ( null , uris . get ( TRACK_URI_INDEX ) ) ; clipData . addItem ( new ClipData . Item ( uris . get ( TRACKPOINTS_URI_INDEX ) ) ) ; clipData . addItem ( new ClipData . Item ( uris . get ( MARKERS_URI_INDEX ) ) ) ; intent . setClipData ( clipData ) ; if ( ( targetPackage != null ) && ( targetClass != null ) ) { Log . i ( TAG , "Starting dashboard activity with explicit intent (package=" + targetPackage + ", class=" + targetClass + ")" ) ; intent . setClassName ( targetPackage , targetClass ) ; } else { Log . i ( TAG , "Starting dashboard activity with generic intent (package=" + targetPackage + ", class=" + targetClass + ")" ) ; } context . startActivity ( intent ) ; }
Send intent to show tracks on a map (needs an another app) as resource URIs.
Send intent to show tracks on a map ( needs an another app ) as resource URIs .