GithubHelp home page GithubHelp logo

Comments (7)

locuturus avatar locuturus commented on August 17, 2024 1

from gpslogger.

mendhak avatar mendhak commented on August 17, 2024 1

v127 is on F-Droid and the Releases section.

from gpslogger.

mendhak avatar mendhak commented on August 17, 2024

Yanno... I actually used to have that path to the file as a link. And I removed it one day... I can't remember exactly why, it was causing crashes on some devices? I'm going to have to dig that out and find out what was wrong, but bringing it back ought to be simple I hope, and I'll see if I can wrap its code in some try catch (and why didn't I do that in the first place!!)

from gpslogger.

locuturus avatar locuturus commented on August 17, 2024

I can only speculate that most file browsers can't open Android/data paths in modern Android and you maybe had used file:/// or other slash delimited intent structure which would only invoke different non-aosp file managers. The intent I provided above should open the Android/data path in the AOSP Files app which can open those paths.

from gpslogger.

mendhak avatar mendhak commented on August 17, 2024

That's exactly it, I found what I used and it matched what you said:

        final Intent intent = new Intent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setDataAndType(Uri.parse("file://" + pathToLinkTo), "resource/folder");
        intent.setAction(Intent.ACTION_VIEW);

OK nice. I'll try the new way when I can find a little time, I'm a bit slow.

from gpslogger.

mendhak avatar mendhak commented on August 17, 2024

This is as far as I got today, not much success but not sure what I'm missing.

                if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                    Uri folderUri = DocumentsContract.buildDocumentUriUsingTree(
                            Uri.parse("content://com.android.externalstorage.documents/tree/primary"),
                            DocumentsContract.getTreeDocumentId(Uri.fromFile(file)));
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    //intent.setDataAndType(folderUri, "resource/folder");
                    intent.setDataAndType(folderUri, "vnd.android.document/directory");
                    intent.addCategory(Intent.CATEGORY_DEFAULT);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, folderUri);
                    startActivity(intent);
                }

Which results in

java.lang.IllegalArgumentException: Invalid URI: file:///storage/emulated/0/Android/data/com.mendhak.gpslogger/files
at android.provider.DocumentsContract.getTreeDocumentId(DocumentsContract.java:1289)
at com.mendhak.gpslogger.ui.fragments.display.GpsSimpleViewFragment$2.onClick(GpsSimpleViewFragment.java:210)
...

from gpslogger.

mendhak avatar mendhak commented on August 17, 2024

Some progress at last. The big problem is that the DocumentsUI app only accepts content:// URIs as you know, but building those URIs is very difficult. I found many unreliable examples that were sort of hacking the URI together but I did manage to figure out a way that uses the framework methods and shouldn't necessarily break that easily.

https://github.com/mendhak/gpslogger/compare/issue-1056-open-folder#diff-7c5b4e0090ce6a46602b6970328f2e9b895a301048523bbb2b99af27880001f1R202-R242

Of course there's a catch. Although the DocumentsContract.buildDocumentUri exists, figuring out the initial part path makes use of StorageVolume.getDirectory, which is Android API level 30, which is Android R.

from gpslogger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.