When my app asks the User to select a text file, Android (Lenovo) presents an options window. The options are image or audio files - no text files or any other type of file. Is there a work-around for this?
Code: Select all
EnableExplicit
Enumeration
#FileIO
#Win
#BtnFile
#BtnExit
EndEnumeration
Declare ExitApp()
Declare ReadCallback(iStatus.i, sFilename.s, iFile.i, iSize.i)
Declare OpenFileRequesterCallback()
Declare ChooseFileEvent()
Declare Win()
Procedure ExitApp()
;#-----------------
CloseWindow(EventWindow())
; ! window.close();
EndProcedure
Procedure ReadCallback(iStatus.i, sFilename.s, iFile.i, iSize.i)
;#--------------------------------------------------------------
Protected iCnt.i
If iStatus = #PB_Status_Loaded
Debug "File: " + sFilename + " Size: " + iSize + " bytes"
Debug "First 3 lines:"
While Eof(#FileIO) = 0 And (iCnt < 3)
Debug ReadString(#FileIO)
iCnt = iCnt + 1
Wend
CloseFile(#FileIO)
ElseIf iStatus = #PB_Status_Error
Debug "Error loading file: " + sFilename
EndIf
EndProcedure
Procedure OpenFileRequesterCallback()
;#-----------------------------------
If NextSelectedFile()
ReadFile(#FileIO, SelectedFileID(), @ReadCallback(), #PB_LocalFile)
EndIf
EndProcedure
Procedure ChooseFileEvent()
;#-------------------------
OpenFileRequester("text/plain", @OpenFileRequesterCallback())
EndProcedure
Procedure Win()
;#-------------
If OpenWindow(#Win, 0, 0, 300, 200, "File Read Test", #PB_Window_ScreenCentered)
ButtonGadget(#BtnFile, 10, 75, 180, 50, "Select File")
ButtonGadget(#BtnExit, 190, 75, 100, 50, "Exit")
BindGadgetEvent(#BtnFile, @ChooseFileEvent())
BindGadgetEvent(#BtnExit, @ExitApp())
EndIf
EndProcedure
Win()