Detecting that SD has been unmounted/mounted

Andris

Active Member
Licensed User
Longtime User
My b4A app manipulates data that exists solely in the "sdcard" folder. I have a functioning Windows program that takes this data and synchronizes it with desktop data. After sync is over and I disconnect the USB, I'd like my b4A app to immediately know that a sync has occurred and trigger Activity.Finish or Activity_Create so that it makes use of the new data.

Is there an easy way to "interrupt" or notify (or close) my b4A app with the sd card unmount/mount event? I could write status info to a file, but then I would have to constantly check it in my b4A app ... there must be an easy interrupt-driven way to do this. Any suggestions?
 

Andris

Active Member
Licensed User
Longtime User
Actually I've solved my own problem :sign0060: and it was far easier than I thought.

My sync app now creates a simple text file with nothing in it, called 'Restart', and places it in my data folder on the Android device. In my app, I test for existence of this file in Activity_Resume. If true, I delete it and issue an Activity_Create:

Sub Activity_Resume

...

'if 'Restart' exists, delete it and restart Activity
If File.Exists(File.DirRootExternal, MyDataDir & "Restart")=True Then
Res=File.Delete(File.DirRootExternal, MyDataDir & "Restart")
Activity_Create(False)​
End If​

End Sub


Seems to work adequately well.
 
Upvote 0
Top