DaveDavenport / gpx-viewer

GPX Viewer is a simple tool to visualize tracks and waypoints stored in a gpx file.
GNU General Public License v2.0
14 stars 6 forks source link

Automation #5

Closed hbcavalcanti closed 3 years ago

hbcavalcanti commented 6 years ago

Hi, I am the author of phone app called Oribooklet that helps doing maps for a sport called Orienteering. GPX Viewer fits very well to show what the mapper is doing in a graphic way, without I had to write a new code to show it. My question is if your app accepts an intents to show a file, called from another application?

DaveDavenport commented 6 years ago

you can call gpx-viewer {filename}. Multiple calls will open in the same program. What more features would you need?

hbcavalcanti commented 6 years ago

Hi Dave,

I made some test and did not succeed. My apps opens GPXViewer that toast a message saying 'file save failed' (see the many attachments). I am using a fixed file called "TestGPXViewer.gpx" that is located at 'Documents' directory. Pls note that the directory created by GPXViewer 'SAVED' is empty. I did also at test addressing the file to ´Documents/Oribooklet´ and the behaviour was the same, no file saved.

Since your app was already opened, I choosed the same file and, in this case, GPXViewer open it fine on both directories above, no complains.

Attached you find out also the way I am doing. Since I am not a senior Android writer so maybe you can help with it (I known your app uses a different language).

albfan commented 3 years ago
public void viewGPXVButton(View view){
    // Get directory Documents
    File root = android.os.Environment.getExternalStoragePublicDirectory
            (Environment.DIRECTORY_DOCUMENTS);
    // Form fileprovider
    String fileProvider = getPackageName()+".fileprovider";
    // Get complete file name. Use a fixed filename
"TestGPXViewer.gpx" just to make shure
    File file = new File(root , "TestGPXViewer.gpx");
    // Get file URI
    try{
        Uri attachment = getUriForFile(Save_File.this, fileProvider, file);
        // Send it
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(attachment,"gpxviewer/gpx");
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        // Check the app is pressent
        if (intent.resolveActivity(getPackageManager())!= null){
            // Yes
            startActivity(intent);
        }else {
            // No
            Toast.makeText(Save_File.this,
                  "GPXViewer not installed", Toast.LENGTH_LONG ).show();
        }
    }
    // Fail to call
    catch (IllegalArgumentException e){
        Toast.makeText(Save_File.this,
                "Fail to open GPXViewer", Toast.LENGTH_LONG ).show();
    }
    finish();
}
albfan commented 3 years ago

I have no idea how a desktop app can run in android.

Closing as non actionable