11-22-2012 05:11 AM
I am developing application on blackberry using phonegap.
I want to listen for event when blackberry device is connected to PC in USB MODE or sync mode.
I saw mediagallery and Filemanager applications showing dailog that application cannot be used when connected to PC in USB mode.
I want to show similar dialog in my application.
Can someone please help on how to do this.
I saw blackberry webworks API
static Boolean blackberry.system.isMassStorageActive ()
which tells if massstorage is active or not.
But i can't keep on query this API every time. I am looking for an API which gives me callback.
Can some one please help.
Solved! Go to Solution.
11-22-2012 10:55 AM
On the Java side, this can be done by implementing a FileSystemListener and the rootChanged method:
public void rootChanged(final int state, String rootName) {
if (rootName.equalsIgnoreCase("sdcard/")) {
if (state == FileSystemListener.ROOT_ADDED) {
/* SD Card is available. */
} else if (state == FileSystemListener.ROOT_REMOVED) {
/* SD Card is not available. */
}
}
}
I have not been able to find a corresponding WebWorks API or community API though, so I believe you will need to create your own custom extension to implement this listener functionality.
https://developer.blackberry.com/html5/documentati
11-26-2012 04:52 AM
Hi,
Thanks for your kind response.
When i connect my device to PC in USB mode will FileSystem give mount/unmount events ?
I just want to confirm becuase i tried solution given by you. it doesn't seem to work for me.
Please help.
Yugandhar.P
@Bangalore,India
11-26-2012 11:16 AM
01-25-2013 06:59 AM
Thanks a lot. Thanks a ton!!
Your solution for Listening to FileSystemListener worked for me.I was not knowing how to register the listener , i found out that some how (FileSystemRegistry.addFileSystemListener(rootListe
I have one more issue now!
I want to know if memory card is present in the device slot or not.
I tried using FileSystemRegistry.listRoots() this will return only system/ even if memory card is present in the slot but phone is connected to PC in USB Drive mode.
Is there any way to detect this low level information? please help. I feel you are the best person.