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
New Contributor
Posts: 4
Registered: ‎12-14-2011
My Device: 9500
My Carrier: vadaphone

My application working fine on simulator but not device getting null pointer exception

hi mates

 

 

please help out with this solution. actually my application working fine on simulator but when i try to run on device its getting null pointer exception and i can also say they not allocate single one memory giving you example like simple Editfield value is not allocate memory getting null .. 

 

 

i have change permission according .. http://stackoverflow.com/questions/7500865/application-is-not-working-in-device-but-working-in-simul...

 

i have give manually permission still the same 

 

Thanks & Regards

Nikita 

Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: My application working fine on simulator but not device getting null pointer exception

welcome to the support forum.

can you debug on the device? a nullpointer should be quite easy to debug.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: My application working fine on simulator but not device getting null pointer exception

[ Edited ]

Hi Nikita,

 

Welcome to the support forum.

 

Start by deploying one of the demo applications, the HelloBlackberry for example.

 

If it works, it either applicative or a build issue.

 

Afterwards, post here the error details (you can even try and search the device log using "alt + L + G+ L +G") so we can give you more help on the problem.

 

E.

New Contributor
Posts: 4
Registered: ‎12-14-2011
My Device: 9500
My Carrier: vadaphone

Re: My application working fine on simulator but not device getting null pointer exception

yes i debug on device and getting null values for all the Classes like editfield , button ya anything not allocate memory  

New Contributor
Posts: 4
Registered: ‎12-14-2011
My Device: 9500
My Carrier: vadaphone

Re: My application working fine on simulator but not device getting null pointer exception

i did it that application is working as i just given one edit field and that edit field focus lost i given one dialog box just taking textbox.get text() its working fine there but my application doesnt work .. here i paste my code which is working fine


import net.rim.device.api.system.Characters;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.browser.field2.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.util.CharacterUtilities;

class TeamListScreen extends UiApplication
{
private MainScreen _screen;
private EditField textboxvalue;
private Field okbutton;

TeamListScreen()
{
textboxvalue = new EditField(){
public void paint(Graphics g)
{
super.paint(g);
int oldColor = Color.GRAY;
g.setBackgroundColor(Color.WHITE);
g.setColor(0x181818);
Font font = this.getFont().derive(Font.EMBOSSED_EFFECT, 54);
this.setFont(font);
g.drawRoundRect(0, 0, getWidth(), getHeight(), 5, 5);
g.setColor(oldColor);
super.paint(g);
}

protected boolean keyChar(char ch, int status, int time) {
if (CharacterUtilities.isDigit(ch)
|| (ch == Characters.BACKSPACE)
|| (ch == Characters.ESCAPE)) {
// Dialog.alert(ch+"1");
return super.keyChar(ch, status, time);
}
return true;
}

public int getPreferredHeight()
{
return super.getPreferredHeight() + 50;
}

};

textboxvalue.setFocusListener(new FocusChangeListener()
{

public void focusChanged(Field field, int eventType)
{
if(eventType== FOCUS_LOST)
{
Dialog.alert(textboxvalue.getText());
}

}
});


okbutton = new ButtonField("OK");
okbutton.setChangeListener(new FieldChangeListener()
{

public void fieldChanged(Field field, int context) {

}
});




_screen = new MainScreen();
_screen.add(textboxvalue);
_screen.add(okbutton);

pushScreen(_screen);

}

public static void main(String[] args)
{
TeamListScreen app = new TeamListScreen();
app.enterEventDispatcher();
}
}
Developer
Posts: 243
Registered: ‎07-22-2011
My Device: BlackBerry Z10
My Carrier: AirTel

Re: My application working fine on simulator but not device getting null pointer exception

Hi Nikitha,

 

Your application is working fine in Device also, The problem is in keyChar function,

i.e you r allowing only digits in your keyChar method so thats y u got null, if u enter any digits it is allowing(In device if u want numbers press Alt key and press numbers ) and dialog box also appering, If u want charecters also then place CharacterUtilities.isCharecter(ch) also...

 

 

Thanks...

----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

Developer
Posts: 87
Registered: ‎07-23-2009
My Device: Z30
My Carrier: XL

Re: My application working fine on simulator but not device getting null pointer exception

and also make sure you doesn't refer any asset/resources (ie. icon) directly from your local PC (ie: drive c://blabla/icon.png) not to your project (ie: /res/img/icon.png)

 

 

New Contributor
Posts: 4
Registered: ‎12-14-2011
My Device: 9500
My Carrier: vadaphone

Re: My application working fine on simulator but not device getting null pointer exception

getting APN is not specified 

Developer
Posts: 27
Registered: ‎02-02-2012
My Device: BB 9800
My Carrier: Airtel

Re: My application working fine on simulator but not device getting null pointer exception

I am also getting same error .

Please help me out