Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Detect SDCARD on App Startup

Yea. I'm not testing it by clicking the icon on the home screen. When its set to UIApplication and theres no screen, it will lock you up... although you can still hold down the menu button until the switch screen dialog comes up. See what the event logger says when you restart the device though.

Trusted Contributor
KJake
Posts: 202
Registered: ‎11-21-2010
My Device: 9700

Re: Detect SDCARD on App Startup

I do get same results as you. As a UI app are you able to see sd card after device restarts and app auto starts?
Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Detect SDCARD on App Startup

yea. worked for both Application and UiApplication.

Trusted Contributor
KJake
Posts: 202
Registered: ‎11-21-2010
My Device: 9700

Re: Detect SDCARD on App Startup

How can it be done as a ui app that displays a screen telling user if sd card found or not found, app set to auto run and after device restarts?

Trusted Contributor
KJake
Posts: 202
Registered: ‎11-21-2010
My Device: 9700

Re: Detect SDCARD on App Startup

[ Edited ]

Not sure why it locks up for me.  I can get an app to see sd card when manually launched, just not after device restarts and app set to auto run.

Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Detect SDCARD on App Startup

... I don't know what you're doing. You said you got the same results. Yes or no, do you see the "sdcard found" string in the event logger after the device restarts. Don't try to open the app, just restart the device and look at the event log. You can change the filter so it only shows entries for "MyApp".

 

If you want a screen, then add a screen. If you keep trying to launch from the ribbon without pushing a screen, its gong to lock up.

 

        if ( sdcardPresent ) {
            FileSystemRegistry.removeFileSystemListener( this );
            synchronized (UiApplication.getEventLock()) {
                pushScreen( new MyScreen( sdcardPresent ) );
            }
        }

 

    private final class MyScreen extends MainScreen {

        public MyScreen(boolean b) {

            add( new LabelField( "added: " + b ) );
        }
    }

 

Trusted Contributor
KJake
Posts: 202
Registered: ‎11-21-2010
My Device: 9700

Re: Detect SDCARD on App Startup

[ Edited ]

Sorry mreed, I wasnt very clear... getting frustrated with what should be a somewhat simple task.  Reinstalling simulators now (received a couple errors) and will test again very shortly and be more clear with my results.

 

Hey I really appreciate all of your help, you've been great.

Trusted Contributor
KJake
Posts: 202
Registered: ‎11-21-2010
My Device: 9700

Re: Detect SDCARD on App Startup

[ Edited ]

I am experiencing issues with debugging/simulator versions and related Eclipse error messages when dubugging using the device. Sorry, working them out now.

However, when I run the code above on my device (7.1.0.523) it works fine and I see label added: true. But, after restart and app auto runs I see label added: false until I close the app then launch it manually.

 

FileSystemRegistry.removeFileSystemListener(this );

synchronized (UiApplication.getEventLock()) {

                pushScreen(new MyScreen( sdcardPresent ) );

            }

}



Must be some sort of timing issue. Is there anything else I can do?

Trusted Contributor
KJake
Posts: 202
Registered: ‎11-21-2010
My Device: 9700

Re: Detect SDCARD on App Startup

[ Edited ]

Sorry, I am also finding after restarting a few more time with sc card in/out that when out the app sometimes locks/doesnt respond at all.  Do you get the same results with no sd card inserted?

Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Detect SDCARD on App Startup

[ Edited ]

Try this. I updated it so theres a screen from the start now, and then it will just add a label as it has something to update. Attached are the project files.

 

As for rebooting with no sdcard... its starting fine, and once I push in the sdcard, it updates the screen saying its available. If you launch the app after startup is complete, its not currently adding the FileSystemListener... but you can update it for that.