Help with forming RunStaticMethod statement please...

tunderin

Member
Licensed User
Longtime User
Hi,

I want to check the state of the SD card before some code executes and am having trouble with the args & types portion of the statement below:

B4X:
Dim r As Reflector
Dim o As Object
o=r.RunStaticMethod("android.os.environment", "getExternalStorageState", ,")

The Android docs that I am using is here.

I've searched the forum and spent the morning experimenting, any help with this would be much appreciated...


tunderin...
 
Last edited:

tunderin

Member
Licensed User
Longtime User
Thanks for your reply thedesolatesoul...

I was trying to do something else, I am testing for the MEDIA_SHARED state - (media is present not mounted, and shared via USB mass storage)

Also, I am trying to further my knowledge of using Reflection to access Android APIs

I had tried r.RunMethod("android.os.environment.getExternalStorageState") but it kept throwing a NullPointerException
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Thanks for your reply thedesolatesoul...

I was trying to do something else, I am testing for the MEDIA_SHARED state - (media is present not mounted, and shared via USB mass storage)

Also, I am trying to further my knowledge of using Reflection to access Android APIs

I had tried r.RunMethod("android.os.environment.getExternalStorageState") but it kept throwing a NullPointerException

Awesome idea.

Anyway this works:

B4X:
Log(r.RunStaticMethod("android.os.Environment", "getExternalStorageState", Null,Null ))
 
Upvote 0

tunderin

Member
Licensed User
Longtime User
Though I could have sworn that I tried nulling them out this morning without success, it certainly works now!

Thanks for taking the time to work this issue, I'm sure that you have other things that needed doing instead.

This will be a handy piece of code though - I saw a post in this forum where a start at boot service was crashing because it was attempting file operations before the OS had mounted the SD card. This would have been perfect...

Thanks again...
 
Upvote 0
Top