Open KML/GPX files in appropriate external map app - android

My Flutter (Android and iOS) app generates KML or GPX files, which works as expected.
Now I want to add a button "Open file" which should open such a system dialog where the installed map or other consuming apps (which can handle such formats) are listed to be chosen.
How can I open this dialog? How can I find the format-related apps and how can I send the file to these apps. I guess, there is a plugin for this, but couldn't find one. It must work on Android and iOS, nice-to have is web support.
I just saw open_file but I am not quite sure, if it works as expected because it doesn't list support for KML/GPX.
Thanks in advance!

If you found a Flutter plug-in that is open source like open_file, you could just add in the MIME types yourself.
For KML format: https://en.wikipedia.org/wiki/Keyhole_Markup_Language
For GPX format: https://en.wikipedia.org/wiki/GPS_Exchange_Format
As the package is open source I was thinking of modifying the code, as the mapping appears to be straight forward:
https://github.com/crazecoder/open_file/blob/master/ios/Classes/OpenFilePlugin.m
and
https://github.com/crazecoder/open_file/blob/master/android/src/main/java/com/crazecoder/openfile/OpenFilePlugin.java
You would need to fork the projects and add in the types you wanted.
Alternately you've posted issue ticket #116
where the repo owner responded with
OpenFile.open("/sdcard/example.txt", type: "text/plain", uti: "public.plain-text");
Do respond if that works, as I was uncertain if both of the different platforms' filetype (uti vs MIME type) works universally in Flutter or if you have platform specific detection code to assign the filetype correctly.

Related

Opening Files from a String Path with Android NDK

I've been going over the Android file access documentation lately, but I seem to be unable to figure out how to actually open a file given as a string containing the path to the file I'd like to open.
What I (eventually) want to accomplish is something like this:
The user selects a specific kind of text file using Intents, receiving a URI to the file. From this I derive the path (getPath()) and pass this string to the native C++ code.
The native C++ opens the file from the string, parsing the content.
Perform some actual work with the above.
From what I've found so far, it seems like it is no longer possible to open files this way (as of SDK version 26 at least):
A hard-coded path to a file I know exists gives me permission denied.
The path itself received from getPath() triggers a No such file or directory error.
One workaround called for opening the file on the Java side using the ContentResolver, and then passing the file descriptor to the native side. This works, but it's problematic: the files can contain references to other files to be opened ("include files") making such a solution of limited use.
Just to make things clear, these files reside locally on the "USB" partition of the Android system, unrelated to the app itself. Not as resources/assets to the APK or anything similar which other questions of this kind seem to require.
In summary, I guess the question is this: Is it possible to open a file, and possibly any other files it refers to, given a path from the Java side of the application? Is there any requirements for doing this, such as requesting the correct permissions for folders or something similar?
As of Android 6.0 (API level 23) you need to request permissions every time your app starts for "dangerous actions" such as accessing the filesystem or reading contacts. The linked pages already have a snippet of code you can copy.
On older phones requesting permissions in the manifest was sufficient, but the target SDK version was recenly upped to 8.0 (=26). If you want to support devices pre-6.0, the Android compatibility library will allow you to call the same API.

Xamarin.Forms - Best way to open dialog to search file

I created an little application in Xamarin.Forms to get the images in my file with XLabs. It work with android and IOS.
But now, i want to import file and i search the best plugin to do that.
I found this : https://developer.xamarin.com/recipes/android/data/files/browse_files/
But it dosent exist with IOS. And i don't know if it's possible (to search and get file)
And it's why i come here, to get answers.
Can you give me a plugin or a solution to get file/path of any file with OpenDialog, intent, or page custom
Thank you
Are you wanting something that can search files outside of your app's directory on iOS or only files within the app's directory?
If you want the former, iOS severely restricts this kind of thing, unlike Android. So it is not possible to do the same thing on iOS that you can do on Android.
Look at the second paragraph here and see that the app is sandboxed which means it cannot view files outside of it's own directories.
That being said other apps can make files available to be shared with other applications, see here.
You can also get access to other files from the device's iCloud account. See this for pre-iOS 8 and this for post iOS 8.

How to find and play videos downloaded by Lynda.com Android or Windows app

There is an App which features downloading their videos for offline viewing via their Android and Windows app. I was wondering where does this app saves these videos and if they are encrypted, how to decrypt and play them?
I am a programmer but I know nothing about Android/windows app development, here is what I have been able to hack so far:
On Android
It seems like it saves videos at
/storage/emulated/0/Android/data/com..android.root/files/videos//encrypted/
These files have no extension, I copied them to my laptop and tried giving different popular media extensions, nothing worked so far in neither of WMP, VLC & Quicktime Player.
I tried to identify file type using TrID (as specified in this link and this utility suggests it is an mp3 file (while it should be a video), I changed the extension to mp3, it did not worked either.
I tried opening the file in ISO buster and several other apps. Finally while trying different things, on android system itself when I choose the option to compute checks, it display some MD5 and SHA-1 values. I am not much familiar with these terms but figured out, these files seems to be encrypted.
If I try to directly open this file on Android, System starts generating Hex Dump and then file explorer crashes.
Now if these files are really the video files and are encrypted, is there a way I can decrypt them and play directly in a video player?
On windows store App in my laptop's Windows 8.1
I found App files are stored at:
C:\Program Files\WindowsApps\.com..com_1.5.0.2_neutral_split.scale-140_
C:\Program Files\WindowsApps\.com..com_1.5.0.2_x64__
C:\Program Files\WindowsApps\.com..com_2015.924.1324.2728_neutral_~_
I was able to figure out how to assign privileges to currently logged in User and gain the access to reach at these paths but couldn't make any further progress to find encrypted or non-encrypted video files in these folders at all.
I understand that if I really just want to download the video files there is much better and easier way - directly log in to their website and use any video grabber application or extension, it's as easy as that, which does works.
But my intention here is not to download videos but rather I am just curious to do ethical hacking for learning and exploring things. Just want to understand whether it is even possible to decrypt, find appropriate extension and play them directly without the app or not. And where does both Android and Windows Apps are actually storing these videos on my own device which I am unable to access/play without App.. huh well done app developers!
Any help or pointers appreciated.
Since Lynda is using HTML5 just click Save as on the video an download it as a mp4....
For Mac users, you can find the offline files at
~/Library/Containers/com.lyndadotcom.lyndaosx/Data/Library/Caches/com.lyndadotcom.lyndaosx/offlnvds/
Cheers!
I was wondering the same thing and I done some exploring with windirstat and found a large bunch of files at:
C:\Users\*username*\AppData\Local\Packages\lynda.com.lynda.com_0dmhem0sv94sr\LocalState\offline\194074
They are .file but the large ones are the videos and they play fine in vlc. Could probably mess around with them and add the .avi or whatever, to the end for completeness if you wanted..
Alright, so the above listed solutions worked for a while but Lynda was smart enough to begin encrypting the downloaded videos. And hence just finding the downloaded content is not good enough anymore.
I could not find a way to decrypt the videos downloaded by the Windows Store app but someone did a great job in decrypting the videos downloaded by the Desktop app (yes, it is different), which is not as popular as the store app.
You can download the desktop version of this app from here.
Find encrypted downloaded vdos here:
C:\Users\\AppData\Local\lynda.com\Lynda.com Desktop App\offline\ldc_dl_courses
and decrypt them using this tool.
This is how:
Browse to:
C:\Users\*User Name*\AppData\Local\Packages\lynda.com.lynda.com_0dmhem0sv94sr\LocalState\offline\*XXXXXX*
Add the extension .mp4 to the files in that folder.
(If you download the files in order they will be alot easier to name because it will be possible to sort by date and time.)
Open a Command Window in that folder (as administrator)
Run the following command in the folder containing your extesionless video files to give all of them .mp4 extesions.
ren *. *.mp4
if you use lynda.com Windows Store App you can find it under
C:\Users{userName}\AppData\Local\Packages\lynda.com.lynda.com_0dmhem0sv94sr\LocalState\offline
for those who use "Lynda Desktop App" to find the exact location for
video files in windows
Run Lynda Desktop App from App menu on top left of app select
"Options" you can find path of downloaded files there "Course
Download location" also you can change it to any path you want,and
its default location is
."C:\Users\{userName}\AppData\Local\lynda.com\Lynda.com Desktop App\offline\ldc_dl_courses"
for those who can not play files using VLC now offline App Encrypt files so it can only decrypted and played with lynda offline App only
if any one needs how to decrypt files I have already developed tool for my personnel use to do so but I think I can not share it for public

How to write an Intent to display file with only desired extensions in Android

I am developing an android app that encrypts/decrypts file.
Once a file is encrypted, its extension changes to filename.encrypted ( here filename is itself a fully qualified filename like hello.pdf, so the encrypted file becomes hello.pdf.encypted).
I have intregrated a file chooser intent in my app, so that user don't need to open a third party intent to choose the files.
My problem is, while user selects to Encrypt a file, he should not be allowed to choose files that are already encrypted i.e. having the extension ".encrypted" and when they are trying to Decrypt a file they should only see the files with the extension ".encrypted".
I have seen a lot of file chooser intents like (https://github.com/iPaulPro/aFileChooser) and (http://code.google.com/p/android-filechooser/) but none have the ability to customize the viewable/selectable files. I read a post (Android file chooser) that says, it cannot be done, but I have seen apps that have implemented this feature.
I am need of help in some resources or links that shows me how is that possible to achieve. I strongly believe the functionality is possible.
Besides, I would also like my app to recognize the extension ".encrypted" when viewed from a third party file manager. I believe that is possible by indicating it in the Android Manifest, but I failed to make it possible. I read this post: Register new file type in Android but could not do it.
Looking for some help here.
I found a library https://github.com/Kaloer/Android-File-Picker-Activity for the thing I wanted to achieve.
They have given us provision to specify allowed extensions using putExtra in the intent.
May be it would be useful to others with similar problems.

Android: How to open a file from inside your application

I've done my fair share of searching for tutorials and guides online, but the only stuff I have found is from 2007 and out of date.
I wanted to know how to open a file from within my current application. For instance, if I click a "Browse" button, it will start another activity of a default file browser on the device (I don't have to implement my own, right?). Obviously I would need it to return the file so I could parse through it as I pleased.
I figured it would be some for of Intent binded to the the button, but I'm now sure.
Bad news - there is not a native "file selector". Good news - this guy made one so you don't have to.
Use Environment.getExternalStorageDirectory() instead of hard-coding the directory path to the SD card. There also seems to be a problem with getting the exact SD card directory using Android 3.0 and 3.1. I have a test app that reads and writes fine in Android 2.3.3 but the same piece of code doesn't work anymore (see https://stackoverflow.com/questions/6545478/android-3-1-sd-card-emulation).

Categories

Resources