Android Question Need help with File Provider/FilePicker.

MrKim

Well-Known Member
Licensed User
Longtime User
Update: Never mind I think I have it figured out. Evidently FilePicker is designed to be opened by another app-with an intent? Since that is not what I was trying to do I wasn't looking at this whole issue correctly. Aaaand I missed the link to the File Provider CLASS which works just fine and gives me what I need. As far as I am concerned this thread can be deleted.

I posted THIS thread where DonManfred referred me to THIS which contains the example filepicker.

I have an intent in that first thread that works with 7.1.1 but not with 8.0 on my Samsung Galaxy S7.

B4X:
Sub OpenPdf(FName As String)
    Dim i As Intent 'Requires a reference to the Phone library
    Try
        i.Initialize(i.ACTION_VIEW, "file:///" & FName)
        i.SetType("application/pdf")
        i.WrapAsIntentChooser("Choose PDF Viewer")
        StartActivity(i)
    Catch
        Msgbox("Error opening " & FName & CRLF & LastException.Message, "Open PDF Error")
    End Try

End Sub


I do not understand the file picker example just reading it so I thought I would run it and follow along, but it does nothing on either device except open a blank, white screen. It does display the message "Open Gmail and add an attachment".

The filepicker activity is never run - at least when I run it in debug mode, nor do I see anywhere in the code that would cause it to be.
I downloaded the code twice in case I had a corrupt file. It made no difference.
I also cannot find any reference to GMAIL anywhere.

The log on both devices is exactly the same:
B4X:
*** Service (starter) Create ***
Using FileProvider? true
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **

Here is the unfiltered log"
B4X:
startAppShortcutOrInfoActivity
START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=b4a.example/.main (has extras)} from uid 10024 on display 0
Failed to apply optimization [4, 0]
ActivityTrigger activityPauseTrigger
BoostFramework() : mPerf = com.qualcomm.qti.Performance@b15e721
BoostFramework() : mPerf = com.qualcomm.qti.Performance@945a746
onPause()
Start proc 7564:b4a.example/u0a248 for activity b4a.example/.main
BoostFramework() : mPerf = com.qualcomm.qti.Performance@d3c591e
Killing 5945:com.android.printspooler/u0a77 (adj 906): empty #17
Killing 5910:com.lenovo.dagent/1000 (adj 906): empty #18
notify app switch quit packageName=com.android.printspooler
cleanUpApplicationRecord -- 5945
notifyAppSwitch resumed: false; pkg:com.android.printspooler
notify app switch quit packageName=com.lenovo.dagent
cleanUpApplicationRecord -- 5910
notifyAppSwitch resumed: false; pkg:com.lenovo.dagent
setSystemUiVisibility vis=8608 mask=ffffffff oldVal=8708 newVal=8608 diff=100
ClassLoader referenced unknown path: /data/app/b4a.example-1/lib/arm64
Bridge logger not enabled.
mAcquireFunc method = public int com.qualcomm.qti.Performance.perfLockAcquire(int,int[])
mReleaseFunc method = public int com.qualcomm.qti.Performance.perfLockRelease()
mAcquireTouchFunc method = public int com.qualcomm.qti.Performance.perfLockAcquireTouch(android.view.MotionEvent,android.util.DisplayMetrics,int,int[])
mIOPStart method = public int com.qualcomm.qti.Performance.perfIOPrefetchStart(int,java.lang.String)
mIOPStop method = public int com.qualcomm.qti.Performance.perfIOPrefetchStop()
BoostFramework() : mPerf = com.qualcomm.qti.Performance@ce23aee
BoostFramework() : mPerf = com.qualcomm.qti.Performance@c5bcb8f
name=>com.google.android.calendar
name=>JHS.VanvasView
name=>com.android.settings
name=>com.google.android.youtube
name=>b4a.example.SwipeList
name=>b4a.example.CropView
name=>com.gamma.bubblelevel
name=>JHS.FabricView
name=>Kims.SwipeList
name=>com.ISS.MobileSPC
name=>com.superlative.admobtest
name=>com.superlative.SwipeList.Ads
name=>com.tinder
name=>com.lenovo.ota
name=>org.korosoft.simplenotepad.android
name=>com.mobilityware.freecell
name=>flipboard.app
name=>b4a.camera2
name=>org.codeaurora.snapcam
name=>anywheresoftware.b4a.samples.mediaplayer
name=>com.android.settings
name=>com.socialnmobile.dictapps.notepad.color.note
name=>com.android.settings
name=>b4a.example
allTasks=>23
*** Service (starter) Create ***
Using FileProvider? true
** Service (starter) Start **
<qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build:  (I762e720a6a)
OpenGL ES Shader Compiler Version: XE031.09.00.04
Build Date: 01/31/17 Tue
Local Branch:
Remote Branch:
Local Patches:
Reconstruct Branch:
Initialized EGL, version 1.4
Swap behavior 1
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Displayed b4a.example/.main: +237ms
wlan0: Control interface command 'SIGNAL_POLL'
CTRL-DEBUG: global_ctrl_sock-sendto: sock=8 sndbuf=229376 outq=0 send_len=48
Open Notification LED, close Battery LED
ActivityTrigger activityStopTrigger
processing priority = NORMAL
Open Notification LED, close Battery LED
accValue============31
mCputempVlaue============31
processing priority = HIGH
Open Notification LED, close Battery LED
wlan0: Control interface command 'SIGNAL_POLL'
CTRL-DEBUG: global_ctrl_sock-sendto: sock=8 sndbuf=229376 outq=0 send_len=48
accValue============31
mCputempVlaue============31
Open Notification LED, close Battery LED
Attempted to remove non-existing token: android.os.Binder@ef5da91
processing priority = NORMAL
Open Notification LED, close Battery LED
accValue============31
mCputempVlaue============31
Open Notification LED, close Battery LED
wlan0: Control interface command 'SIGNAL_POLL'
CTRL-DEBUG: global_ctrl_sock-sendto: sock=8 sndbuf=229376 outq=0 send_len=48
processing priority = HIGH
Open Notification LED, close Battery LED
accValue============31
mCputempVlaue============31
Open Notification LED, close Battery LED
processing priority = LOW
wlan0: Control interface command 'SIGNAL_POLL'

I am connected via USB. The app was compiled for release. I am running B4A 8.50
Any help greatly appreciated.

Questions:
In trying to understand this code (FilePicker) am I to understand that the external app (in my example here a pdf viewer) is going to be reading from my apps INTERNAL storage after 24?

There is a comment for SetFileUriAsIntentData:
B4X:
'Resets the type field. Make sure to call Intent.SetType after calling this method
But a search of the code shows a call to SetFileUriAsIntentData but SetType is never called. Does SetType need to be called and what should it be set TO?
 
Last edited:
Top