03-01-2012 07:22 AM - edited 03-01-2012 07:45 AM
Hi There,
i have a small problem that come at the after installation of my application when i press my application icon it says Null pointer exception it comes first time only next time onwards it's working perfectly alright. i don't know why this exception came. after installation i am taking into loginscreen of my application. here i am loading Images. and i found some images are returning null. that path is correct and afterthrowing thiswhen i press ok in that exception dialog box and next time i try to lanch the app it's working fine it won't say any exception.
Please anyone help me.
Thank you in advance.
Solved! Go to Solution.
03-01-2012 07:40 AM
Maybe you are using files on the SDCard which is not mounted immediatly when you launch the simulator (the simulator start the application before load the sdcard)
You can use this function to see if a sdcard is here.
public static boolean isSDCardAvailable()
{
boolean res = false;
String root = null;
Enumeration e = FileSystemRegistry.listRoots();
while (e.hasMoreElements())
{
root = (String) e.nextElement();
if( root.equalsIgnoreCase("sdcard/") )
{
res = true;
}
}
return res;
}
You have to use this function, and if it gives you false, push something which wait until the card is mounted.
For instance, this class.
public class ScreenNoSDCard extends MainScreen implements FileSystemListener
{
public ScreenNoSDCard()
{
super();
add(new LabelField("Cette application fonctionne uniquement avec la présence d'une carte mémoire externe."));
add(new LabelField("Veuillez insérer une carte mémoire ou quitter l'application."));
FileSystemRegistry.addFileSystemListener(this);
}
public void rootChanged(int state, String rootName)
{
if( state == ROOT_ADDED )
{
if( rootName.equalsIgnoreCase("sdcard/") )
{
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
UiApplication.getUiApplication().popScreen(ScreenN oSDCard.this);
UiApplication.getUiApplication().pushScreen(new ScreenCache());
}
});
}
}
}
}You won't see this screen, it will be pop before you actually see the application screen.
03-01-2012 07:44 AM
Thank you smathis,
I am not using the files in sd card. in my project placed those images.
In simulator it's working fine.
While on device i am getting this error.
03-01-2012 08:12 AM
Does this happen at device startup? Once the device is started up you should not have any problems with the SD Card.
If you are seeing this the first time you run, then install and debug on device, then start you app. You will get more information about what is going on, and hopefully it will even give you a nice breakpoint.
03-01-2012 08:18 AM
Hi Peter,
Thank you for the replay.
I am tried to debug the app at the time of installation before throwing the exception my debug session was closed.
i tried several times. peter but still cann't find the solution. i got this problem after updation of my eclipse. i think this is a build problem?
Can u please help me?
03-01-2012 10:07 AM
You haven't answered my question regarding when it happens, I presume it is on installation and NOT at device startup.
Do you have any 'autostart' processing?
I would next look at the device log (ALT L-G-L-G) and see if there is an entry in there related to the HPE. I suspect there will be, and it will have the stack trace. You should be able to track it down from there.
03-01-2012 10:16 AM
After Installation. i got this error Peter.
yes i checked there but here it shows no detail message.and
it gives me some GUID and etc...
03-01-2012 10:26 AM - edited 03-01-2012 10:33 AM
An uncaught exception will give you a stack trace. click on it to display the detail.
And please answer all my questions.
03-02-2012 01:29 AM
Thank you for the replay peter.
Problem solved the problem in my code deactive method.