I wrote an app for my employer a while back and it has been working fine. I recently changed the manifest to target API 23 and added support for Runtime permissions and it continued to work as expected.
My employer recently upgraded our company-provided cell phones and we went from the Galaxy S7 to the Galaxy S9. I forget which version of Android the S7 had been on when we switched over but it had obviously been updated several times over the years we had it.
On the S9 now, we are running Android 8.0. Since changing over to the new phones though, one part of the app no longer works.
We have KMZ files that show our pipeline map overlayed in Google Earth. On the new phones, the KMZ files get copied to an external folder properly but Google Earth fails to load them.
I ran across the file provider tutorial and tried getting it to work that way but had no luck. I'm not even sure if that is where the problem lies or not.
Is anyone familiar with how to properly open a KMZ file with Google Earth on the latest version of Android?
My employer recently upgraded our company-provided cell phones and we went from the Galaxy S7 to the Galaxy S9. I forget which version of Android the S7 had been on when we switched over but it had obviously been updated several times over the years we had it.
On the S9 now, we are running Android 8.0. Since changing over to the new phones though, one part of the app no longer works.
We have KMZ files that show our pipeline map overlayed in Google Earth. On the new phones, the KMZ files get copied to an external folder properly but Google Earth fails to load them.
I ran across the file provider tutorial and tried getting it to work that way but had no luck. I'm not even sure if that is where the problem lies or not.
Is anyone familiar with how to properly open a KMZ file with Google Earth on the latest version of Android?
B4X:
Sub CopyKMZ (sFN As String) As Boolean
Dim sFolder As String = File.DirDefaultExternal 'RTPerm.GetSafeDirDefaultExternal ("")
If File.ExternalReadable = True Then
If File.Exists (sFolder, sFN) = True Then Return True ' Already there
End If
If File.ExternalWritable = True Then
Try
File.Copy (File.DirAssets, sFN, sFolder, sFN)
Return True
Catch
ToastMessageShow ("Failed to copy " & Chr(34) & sFN & Chr(34) & " to public folder. Is the phone's storage full?", False)
Return False
End Try
Else ' Not writable
ToastMessageShow ("Failed to copy " & Chr(34) & sFN & Chr(34) & " to public folder. App needs permission to access external folder.", True)
Return False
End If
End Sub
Sub ShowAssetsinGE (iArea As Int)
Dim sAreaFilename As String
Select Case iArea
Case 0
sAreaFilename = "Hammond.kmz"
Case 1
sAreaFilename = "WoodRiver.kmz"
Case 2
sAreaFilename = "Glenpool.kmz"
Case 3
sAreaFilename = "Greenville.kmz"
Case 4
sAreaFilename = "Arlington.kmz"
Case 5
sAreaFilename = "Houston.kmz"
Case 6
sAreaFilename = "PortArthur.kmz"
Case 7
Msgbox ("There are no pipeline assets associated with the Tulsa area.", Application.LabelName)
Return
End Select
RTPerm.CheckAndRequest (RTPerm.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait for Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then
If CopyKMZ (sAreaFilename) = False Then
Msgbox ("Unable to load the pipeline map into Google Earth because the file could not be copied." & CRLF & CRLF & "Is your device low on space?", "Oops!")
Return
End If
If File.ExternalReadable = False Then
Msgbox ("Unable to load the pipeline map into Google Earth because the file could not be accessed.", "Oops!")
Return
End If
'Should be good regarding external storage
Dim iIntent As Intent, sPackage As String
Dim sFolder As String = File.DirDefaultExternal 'RTPerm.GetSafeDirDefaultExternal ("")
iIntent.Initialize(iIntent.ACTION_VIEW, "file://" & sFolder & "/" & sAreaFilename)
sPackage = "com.google.earth/.EarthActivity"
iIntent.SetComponent(sPackage)
Try
ToastMessageShow ("Loading assets into Google Earth." & CRLF & "Please wait...", True):Sleep(0)
StartActivity(iIntent)
Catch
If Msgbox2 ("Failed to start the Google Earth app." & CRLF & CRLF & "Would you like to try installing it now?", "Uh-oh!", "Yes", "No", "", Null) = DialogResponse.POSITIVE Then InstallApp (0)
End Try
Else
Msgbox ("In order for this app to display pipeline assets in Google Earth, you must grant it permission to access files on your device so that the asset files can be copied to a storage location accessible by other apps.", "Permission required!")
End If
End Sub