I'm implementing file transfer through Android Beam in my app.
I have 2 phone I can use for testing: a Samsung Galaxy A6 and my Nexus 5x.
On the Galaxy there is no problem on the receiving side. The file is download in the "Download" folder and I get the path for the file from the intent, just like it's explained in the android dev page.
On my Nexus 5x the file get downloaded in the "beam" folder, but from the intent I get "beam/beam/file.txt" and I have to manually remove one of the "beam" in the path.
Why the hell is this happening?
And even if I managed to remove the "beam" part from it, I still miss the complete path to the file.
While on the galaxy the path from the intent is
/storage/emulated/0/Download/...
On my nexus 5x is just:
beam/beam/...
Just.... what?
Is there anyway I can fix this or do I manually have to check if the beam folder is in the external or internal memory and then add the correct prefix?
Currently this is the code I use to retrieve the path when handling the "view intent" that should contain the file I received:
mIntent.data?.also { beamUri ->
val pathSegments = beamUri.pathSegments
var path : String? = beamUri.path
// Edge Case for Nexus 5X
if(pathSegments.size == 3){
if((pathSegments[0] == pathSegments[1]) && pathSegments[0] == "beam"){
path = "${pathSegments.first()}${File.separator}${pathSegments.last()}"
}
}
...
}
EDIT 1: Logging beamUri as suggested in the comments below, on the nexus 5x, the file is received as a content and on the Galaxy as a file.
I'll now implement the method to deal with content as well, but why the difference between the two?